Django 1.8+ compatibility
Update odsreg so that it runs with Django 1.8: - Move base files under an odsreg module, update .gitignore - Update module paths - Update manage.py to Django 1.8 version - Update instructions in README.rst - Remove 'null has no effect on ManyToManyField' warning Update odsreg so that it runs with Django 1.9: - Update management command arg handling - Use url instead of patterns in urls.py - Move from TEMPLATE_* variables to TEMPLATES Co-Authored-By: Tom Fifield <tom@openstack.org> Change-Id: Ic18bddd29053ca0187889bb8a371048b2ad3fdb9
This commit is contained in:
parent
e03524ba65
commit
6b962fa3e2
4
.gitignore
vendored
4
.gitignore
vendored
@ -4,5 +4,7 @@
|
|||||||
*.sqlite
|
*.sqlite
|
||||||
*.db
|
*.db
|
||||||
*~
|
*~
|
||||||
local_settings.py
|
.venv
|
||||||
|
odsreg/local_settings.py
|
||||||
|
event.json
|
||||||
slots.json
|
slots.json
|
||||||
|
13
README.rst
13
README.rst
@ -18,14 +18,14 @@ Prerequisites
|
|||||||
-------------
|
-------------
|
||||||
|
|
||||||
You'll need the following Python modules installed:
|
You'll need the following Python modules installed:
|
||||||
- django (1.4+)
|
- django (1.8+)
|
||||||
- python-django-auth-openid
|
- python-django-auth-openid
|
||||||
|
|
||||||
OR
|
OR
|
||||||
|
|
||||||
If you are using pip with or without a venv,
|
If you are using pip with or without a venv,
|
||||||
you can use the following commands instead:
|
you can use the following commands instead:
|
||||||
- pip install django==1.4
|
- pip install django
|
||||||
- pip install python-openid
|
- pip install python-openid
|
||||||
- pip install django-openid-auth
|
- pip install django-openid-auth
|
||||||
|
|
||||||
@ -33,11 +33,14 @@ you can use the following commands instead:
|
|||||||
Configuration and Usage
|
Configuration and Usage
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
Copy local_settings.py.sample to local_settings.py and change
|
Copy odsreg/local_settings.py.sample to odsreg/local_settings.py and change
|
||||||
settings there.
|
settings there. In particular you should set DEBUG=True or ALLOWED_HOSTS.
|
||||||
|
|
||||||
Create empty database:
|
Create empty database:
|
||||||
./manage.py syncdb
|
./manage.py migrate
|
||||||
|
|
||||||
|
Create a superuser:
|
||||||
|
./manage.py createsuperuser
|
||||||
|
|
||||||
Copy event.json.sample to event.json and edit the file to match
|
Copy event.json.sample to event.json and edit the file to match
|
||||||
the event and topics you want to have. Then run:
|
the event and topics you want to have. Then run:
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from odsreg.cfp.models import Topic, Proposal, Event, Comment
|
from cfp.models import Topic, Proposal, Event, Comment
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
from django.forms import ModelForm, CharField, Textarea
|
from django.forms import ModelForm, CharField, Textarea
|
||||||
|
|
||||||
from odsreg.cfp.models import Comment, Proposal
|
from cfp.models import Comment, Proposal
|
||||||
|
|
||||||
|
|
||||||
class CommentForm(ModelForm):
|
class CommentForm(ModelForm):
|
||||||
|
@ -16,20 +16,22 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
from odsreg.cfp.models import Event, Topic
|
from cfp.models import Event, Topic
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
args = '<description.json>'
|
args = '<description.json>'
|
||||||
help = 'Create topics from JSON description'
|
help = 'Create topics from JSON description'
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def add_arguments(self, parser):
|
||||||
|
parser.add_argument('descriptive_json')
|
||||||
|
|
||||||
if len(args) != 1:
|
def handle(self, *args, **options):
|
||||||
|
if 'descriptive_json' not in options.keys():
|
||||||
raise CommandError('Incorrect arguments')
|
raise CommandError('Incorrect arguments')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(args[0]) as f:
|
with open(options['descriptive_json']) as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
raise CommandError("Malformed JSON: %s" % exc.message)
|
raise CommandError("Malformed JSON: %s" % exc.message)
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
from odsreg.cfp.models import Event
|
from cfp.models import Event
|
||||||
|
|
||||||
|
|
||||||
class EventMiddleware():
|
class EventMiddleware():
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
from odsreg.cfp.utils import validate_bp
|
from cfp.utils import validate_bp
|
||||||
|
|
||||||
|
|
||||||
class Event(models.Model):
|
class Event(models.Model):
|
||||||
|
24
cfp/urls.py
24
cfp/urls.py
@ -13,16 +13,18 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf.urls.defaults import *
|
from django.conf.urls import url
|
||||||
|
|
||||||
|
from cfp import views
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = patterns('odsreg.cfp.views',
|
urlpatterns = [
|
||||||
(r'^details/(\d+)$', 'details'),
|
url(r'^details/(\d+)$', views.details),
|
||||||
(r'^edit/(\d+)$', 'edit'),
|
url(r'^edit/(\d+)$', views.edit),
|
||||||
(r'^create$', 'create'),
|
url(r'^create$', views.create),
|
||||||
(r'^review/(\d+)$', 'review'),
|
url(r'^review/(\d+)$', views.review),
|
||||||
(r'^switch/(\d+)$', 'switch'),
|
url(r'^switch/(\d+)$', views.switch),
|
||||||
(r'^delete/(\d+)$', 'delete'),
|
url(r'^delete/(\d+)$', views.delete),
|
||||||
(r'^topic/(\d+)$', 'topiclist'),
|
url(r'^topic/(\d+)$', views.topiclist),
|
||||||
(r'^topicstatus$', 'topicstatus'),
|
url(r'^topicstatus$', views.topicstatus),
|
||||||
)
|
]
|
||||||
|
@ -22,10 +22,10 @@ from django.http import HttpResponseRedirect, HttpResponseForbidden
|
|||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils.encoding import smart_str
|
from django.utils.encoding import smart_str
|
||||||
|
|
||||||
from odsreg.cfp.models import Proposal, Topic, Comment
|
from cfp.models import Proposal, Topic, Comment
|
||||||
from odsreg.cfp.forms import ProposalForm, ProposalEditForm, CommentForm
|
from cfp.forms import ProposalForm, ProposalEditForm, CommentForm
|
||||||
from odsreg.cfp.forms import ProposalReviewForm, ProposalSwitchForm
|
from cfp.forms import ProposalReviewForm, ProposalSwitchForm
|
||||||
from odsreg.cfp.utils import linkify, is_editable, topiclead
|
from cfp.utils import linkify, is_editable, topiclead
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
33
manage.py
33
manage.py
@ -1,29 +1,10 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
import os
|
||||||
# Copyright 2011 Thierry Carrez <thierry@openstack.org>
|
import sys
|
||||||
# All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from django.core.management import execute_manager
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
import settings # Assumed to be in the same directory.
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
sys.stderr.write("Error: Can't find the file 'settings.py'\n")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
execute_manager(settings)
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "odsreg.settings")
|
||||||
|
|
||||||
|
from django.core.management import execute_from_command_line
|
||||||
|
|
||||||
|
execute_from_command_line(sys.argv)
|
||||||
|
@ -28,8 +28,8 @@ DATABASES = {
|
|||||||
SECRET_KEY = 'generateRandomOneHere'
|
SECRET_KEY = 'generateRandomOneHere'
|
||||||
|
|
||||||
# Run in production
|
# Run in production
|
||||||
|
ALLOWED_HOSTS = []
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
TEMPLATE_DEBUG = DEBUG
|
|
||||||
#OPENID_USE_AS_ADMIN_LOGIN = True
|
#OPENID_USE_AS_ADMIN_LOGIN = True
|
||||||
|
|
||||||
# Emails
|
# Emails
|
@ -21,7 +21,6 @@ import os
|
|||||||
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
|
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
TEMPLATE_DEBUG = DEBUG
|
|
||||||
|
|
||||||
SERVE_STATIC = True
|
SERVE_STATIC = True
|
||||||
|
|
||||||
@ -42,18 +41,28 @@ STATIC_URL = '/media/'
|
|||||||
SECRET_KEY = 'changemeInLocalSettings'
|
SECRET_KEY = 'changemeInLocalSettings'
|
||||||
|
|
||||||
# List of callables that know how to import templates from various sources.
|
# List of callables that know how to import templates from various sources.
|
||||||
TEMPLATE_LOADERS = (
|
TEMPLATES = [
|
||||||
'django.template.loaders.filesystem.Loader',
|
{
|
||||||
'django.template.loaders.app_directories.Loader',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
)
|
'DIRS': [
|
||||||
|
# insert your TEMPLATE_DIRS here
|
||||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
],
|
||||||
"django.contrib.auth.context_processors.auth",
|
'APP_DIRS': True,
|
||||||
"django.core.context_processors.debug",
|
'OPTIONS': {
|
||||||
"django.core.context_processors.i18n",
|
'context_processors': [
|
||||||
"django.core.context_processors.media",
|
# Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
|
||||||
"django.core.context_processors.request",
|
# list if you haven't customized them:
|
||||||
)
|
'django.contrib.auth.context_processors.auth',
|
||||||
|
'django.template.context_processors.debug',
|
||||||
|
'django.template.context_processors.i18n',
|
||||||
|
'django.template.context_processors.media',
|
||||||
|
'django.template.context_processors.static',
|
||||||
|
'django.template.context_processors.tz',
|
||||||
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
MIDDLEWARE_CLASSES = (
|
MIDDLEWARE_CLASSES = (
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
@ -61,7 +70,7 @@ MIDDLEWARE_CLASSES = (
|
|||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'odsreg.cfp.middleware.EventMiddleware',
|
'cfp.middleware.EventMiddleware',
|
||||||
)
|
)
|
||||||
|
|
||||||
ROOT_URLCONF = 'odsreg.urls'
|
ROOT_URLCONF = 'odsreg.urls'
|
||||||
@ -74,8 +83,8 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'django_openid_auth',
|
'django_openid_auth',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'odsreg.cfp',
|
'cfp',
|
||||||
'odsreg.scheduling',
|
'scheduling',
|
||||||
]
|
]
|
||||||
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
AUTHENTICATION_BACKENDS = (
|
||||||
@ -86,6 +95,7 @@ AUTHENTICATION_BACKENDS = (
|
|||||||
# Should users be created when new OpenIDs are used to log in?
|
# Should users be created when new OpenIDs are used to log in?
|
||||||
OPENID_CREATE_USERS = True
|
OPENID_CREATE_USERS = True
|
||||||
OPENID_STRICT_USERNAMES = True
|
OPENID_STRICT_USERNAMES = True
|
||||||
|
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
|
||||||
|
|
||||||
# Can we reuse existing users?
|
# Can we reuse existing users?
|
||||||
OPENID_REUSE_USERS = True
|
OPENID_REUSE_USERS = True
|
@ -13,17 +13,18 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf.urls.defaults import *
|
from django.conf.urls import include, url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from cfp import views
|
||||||
|
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = [
|
||||||
(r'^openid/', include('django_openid_auth.urls')),
|
url(r'^openid/', include('django_openid_auth.urls')),
|
||||||
(r'^$', 'odsreg.cfp.views.list'),
|
url(r'^$', views.list),
|
||||||
(r'^cfp/', include('odsreg.cfp.urls')),
|
url(r'^cfp/', include('cfp.urls')),
|
||||||
(r'^scheduling/', include('odsreg.scheduling.urls')),
|
url(r'^scheduling/', include('scheduling.urls')),
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
(r'^logout$', 'odsreg.cfp.views.dologout'),
|
url(r'^logout$', views.dologout),
|
||||||
)
|
]
|
@ -13,7 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from odsreg.scheduling.models import Slot, Room
|
from scheduling.models import Slot, Room
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
from django.forms import ModelForm
|
from django.forms import ModelForm
|
||||||
|
|
||||||
from odsreg.scheduling.models import Slot
|
from scheduling.models import Slot
|
||||||
|
|
||||||
|
|
||||||
class SlotForm(ModelForm):
|
class SlotForm(ModelForm):
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
from odsreg.cfp.models import Proposal, Topic
|
from cfp.models import Proposal, Topic
|
||||||
|
|
||||||
|
|
||||||
class Room(models.Model):
|
class Room(models.Model):
|
||||||
@ -33,7 +33,7 @@ class Slot(models.Model):
|
|||||||
start_time = models.CharField(max_length=16)
|
start_time = models.CharField(max_length=16)
|
||||||
room = models.ForeignKey(Room)
|
room = models.ForeignKey(Room)
|
||||||
topic = models.ForeignKey(Topic)
|
topic = models.ForeignKey(Topic)
|
||||||
proposals = models.ManyToManyField(Proposal, blank=True, null=True)
|
proposals = models.ManyToManyField(Proposal, blank=True)
|
||||||
title = models.CharField(max_length=60, blank=True,
|
title = models.CharField(max_length=60, blank=True,
|
||||||
verbose_name="Override title with",
|
verbose_name="Override title with",
|
||||||
help_text="Default title is the title of the first proposal. You can"
|
help_text="Default title is the title of the first proposal. You can"
|
||||||
|
@ -13,13 +13,14 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf.urls.defaults import *
|
from django.conf.urls import url
|
||||||
|
|
||||||
|
from scheduling import views
|
||||||
|
|
||||||
urlpatterns = patterns('odsreg.scheduling.views',
|
urlpatterns = [
|
||||||
(r'^(\d+)$', 'scheduling'),
|
url(r'^(\d+)$', views.scheduling),
|
||||||
(r'^edit/(\d+)$', 'edit'),
|
url(r'^edit/(\d+)$', views.edit),
|
||||||
(r'^swap/(\d+)$', 'swap'),
|
url(r'^swap/(\d+)$', views.swap),
|
||||||
(r'^publish/(\d+)$', 'publish'),
|
url(r'^publish/(\d+)$', views.publish),
|
||||||
(r'^graph/(\d+)$', 'graph'),
|
url(r'^graph/(\d+)$', views.graph),
|
||||||
)
|
]
|
||||||
|
@ -19,13 +19,13 @@ import urllib2
|
|||||||
from django.http import HttpResponseRedirect, HttpResponseForbidden
|
from django.http import HttpResponseRedirect, HttpResponseForbidden
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils.encoding import smart_str
|
from django.utils.encoding import smart_str
|
||||||
from odsreg.cfp.models import Proposal, Topic, Event
|
from cfp.models import Proposal, Topic, Event
|
||||||
from odsreg.cfp.utils import topiclead
|
from cfp.utils import topiclead
|
||||||
from odsreg.scheduling.forms import SlotForm
|
from scheduling.forms import SlotForm
|
||||||
from odsreg.scheduling.models import Slot
|
from scheduling.models import Slot
|
||||||
from odsreg.scheduling.utils import combined_id, combined_title
|
from scheduling.utils import combined_id, combined_title
|
||||||
from odsreg.scheduling.utils import combined_description, full_description
|
from scheduling.utils import combined_description, full_description
|
||||||
from odsreg.scheduling.utils import htmlize, end_time
|
from scheduling.utils import htmlize, end_time
|
||||||
|
|
||||||
|
|
||||||
def scheduling(request, topicid):
|
def scheduling(request, topicid):
|
||||||
|
Loading…
Reference in New Issue
Block a user