From 5c07d3e9454b2c8454058ef7598010855a540053 Mon Sep 17 00:00:00 2001 From: Martin Brochhaus Date: Sat, 11 Jan 2014 14:50:04 +0800 Subject: [PATCH 1/2] Django 1.6 compatibility --- symposion/boxes/urls.py | 4 ++-- symposion/cms/urls.py | 2 +- symposion/conference/urls.py | 2 +- symposion/proposals/models.py | 16 +++++++--------- symposion/proposals/urls.py | 2 +- symposion/proposals/views.py | 7 ++++++- symposion/reviews/urls.py | 2 +- symposion/schedule/urls.py | 2 +- symposion/speakers/urls.py | 2 +- symposion/sponsorship/urls.py | 6 +++--- symposion/teams/urls.py | 2 +- 11 files changed, 25 insertions(+), 22 deletions(-) diff --git a/symposion/boxes/urls.py b/symposion/boxes/urls.py index dc57fe6b..993ec136 100644 --- a/symposion/boxes/urls.py +++ b/symposion/boxes/urls.py @@ -1,6 +1,6 @@ -from django.conf.urls.defaults import url, patterns +from django.conf.urls import url, patterns urlpatterns = patterns("symposion.boxes.views", url(r"^([-\w]+)/edit/$", "box_edit", name="box_edit"), -) \ No newline at end of file +) diff --git a/symposion/cms/urls.py b/symposion/cms/urls.py index 3297ce53..355746ea 100644 --- a/symposion/cms/urls.py +++ b/symposion/cms/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import url, patterns +from django.conf.urls import url, patterns PAGE_RE = r"(([\w-]{1,})(/[\w-]{1,})*)/" diff --git a/symposion/conference/urls.py b/symposion/conference/urls.py index 6bd44c16..90ae79f8 100644 --- a/symposion/conference/urls.py +++ b/symposion/conference/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url urlpatterns = patterns("symposion.conference.views", diff --git a/symposion/proposals/models.py b/symposion/proposals/models.py index e70af550..6d51bc60 100644 --- a/symposion/proposals/models.py +++ b/symposion/proposals/models.py @@ -1,4 +1,3 @@ -import datetime import os import uuid @@ -6,6 +5,7 @@ from django.core.urlresolvers import reverse from django.db import models from django.db.models import Q from django.utils.translation import ugettext_lazy as _ +from django.utils.timezone import now from django.contrib.auth.models import User @@ -37,20 +37,18 @@ class ProposalSection(models.Model): @classmethod def available(cls): - now = datetime.datetime.now() return cls._default_manager.filter( - Q(start__lt=now) | Q(start=None), - Q(end__gt=now) | Q(end=None), + Q(start__lt=now()) | Q(start=None), + Q(end__gt=now()) | Q(end=None), Q(closed=False) | Q(closed=None), ) def is_available(self): if self.closed: return False - now = datetime.datetime.now() - if self.start and self.start > now: + if self.start and self.start > now(): return False - if self.end and self.end < now: + if self.end and self.end < now(): return False return True @@ -96,7 +94,7 @@ class ProposalBase(models.Model): help_text=_("Anything else you'd like the program committee to know when making their selection: your past experience, etc. This is not made public. Edit using Markdown.") ) submitted = models.DateTimeField( - default=datetime.datetime.now, + default=now, editable=False, ) speaker = models.ForeignKey("speakers.Speaker", related_name="proposals") @@ -166,7 +164,7 @@ class SupportingDocument(models.Model): proposal = models.ForeignKey(ProposalBase, related_name="supporting_documents") uploaded_by = models.ForeignKey(User) - created_at = models.DateTimeField(default=datetime.datetime.now) + created_at = models.DateTimeField(default=now) file = models.FileField(upload_to=uuid_filename) description = models.CharField(max_length=140) diff --git a/symposion/proposals/urls.py b/symposion/proposals/urls.py index 85e2bb1c..3a53558f 100644 --- a/symposion/proposals/urls.py +++ b/symposion/proposals/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url urlpatterns = patterns("symposion.proposals.views", diff --git a/symposion/proposals/views.py b/symposion/proposals/views.py index cf532c2b..9754c93f 100644 --- a/symposion/proposals/views.py +++ b/symposion/proposals/views.py @@ -6,7 +6,12 @@ from django.core.exceptions import ObjectDoesNotExist from django.db.models import Q from django.http import Http404, HttpResponse, HttpResponseForbidden from django.shortcuts import render, redirect, get_object_or_404 -from django.utils.hashcompat import sha_constructor + +try: + from hashlib import sha1 as sha_constructor +except ImportError: + from django.utils.hashcompat import sha_constructor + from django.views import static from django.contrib import messages diff --git a/symposion/reviews/urls.py b/symposion/reviews/urls.py index 564bd35e..c918d2f1 100644 --- a/symposion/reviews/urls.py +++ b/symposion/reviews/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns, url +from django.conf.urls import patterns, url urlpatterns = patterns("symposion.reviews.views", diff --git a/symposion/schedule/urls.py b/symposion/schedule/urls.py index 58890827..049aa7da 100644 --- a/symposion/schedule/urls.py +++ b/symposion/schedule/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import url, patterns +from django.conf.urls import url, patterns urlpatterns = patterns("symposion.schedule.views", diff --git a/symposion/speakers/urls.py b/symposion/speakers/urls.py index fa7055cf..fb30e787 100644 --- a/symposion/speakers/urls.py +++ b/symposion/speakers/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url urlpatterns = patterns("symposion.speakers.views", diff --git a/symposion/sponsorship/urls.py b/symposion/sponsorship/urls.py index e5d32bb0..c7dc581c 100644 --- a/symposion/sponsorship/urls.py +++ b/symposion/sponsorship/urls.py @@ -1,9 +1,9 @@ -from django.conf.urls.defaults import patterns, url -from django.views.generic.simple import direct_to_template +from django.conf.urls import patterns, url +from django.views.generic import TemplateView urlpatterns = patterns("symposion.sponsorship.views", - url(r"^$", direct_to_template, {"template": "sponsorship/list.html"}, name="sponsor_list"), + url(r"^$", TemplateView.as_view(template_name="sponsorship/list.html"), name="sponsor_list"), url(r"^apply/$", "sponsor_apply", name="sponsor_apply"), url(r"^add/$", "sponsor_add", name="sponsor_add"), url(r"^(?P\d+)/$", "sponsor_detail", name="sponsor_detail"), diff --git a/symposion/teams/urls.py b/symposion/teams/urls.py index 01145f41..a5eb3b8e 100644 --- a/symposion/teams/urls.py +++ b/symposion/teams/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url urlpatterns = patterns("symposion.teams.views", From bf4b682e8af7ef2b6fc6c292c257e7c13e3e55e5 Mon Sep 17 00:00:00 2001 From: Martin Brochhaus Date: Sun, 18 May 2014 15:50:51 +0800 Subject: [PATCH 2/2] Bugfix: Cannot unassign presentation on schedule/edit view --- symposion/schedule/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/symposion/schedule/models.py b/symposion/schedule/models.py index dc070917..e5680d90 100644 --- a/symposion/schedule/models.py +++ b/symposion/schedule/models.py @@ -79,8 +79,9 @@ class Slot(models.Model): Unassign the associated content with this slot. """ if self.content and self.content.slot_id: - self.content.slot = None - self.content.save() + presentation = self.content + presentation.slot = None + presentation.save() @property def content(self):