From a6e1020ec95557221afe7313ae69b38368deeee5 Mon Sep 17 00:00:00 2001 From: Tasos Katsoulas Date: Tue, 3 Feb 2015 14:47:37 +0200 Subject: [PATCH] Replace ROTM_NOMINATION_END_DATE with a function. --- remo/profiles/views.py | 4 ++-- remo/voting/tasks.py | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/remo/profiles/views.py b/remo/profiles/views.py index 504048ce3..c515a01cf 100644 --- a/remo/profiles/views.py +++ b/remo/profiles/views.py @@ -23,7 +23,7 @@ from remo.events.utils import get_events_for_user from remo.profiles.models import UserProfile, UserStatus from remo.profiles.models import FunctionalArea -from remo.voting.tasks import ROTM_NOMINATION_END_DATE +from remo.voting.tasks import rotm_nomination_end_date USERNAME_ALGO = getattr(settings, 'BROWSERID_USERNAME_ALGO', default_username_algo) @@ -153,7 +153,7 @@ def view_profile(request, display_name): instance=user.userprofile) usergroups = user.groups.filter(Q(name='Mentor') | Q(name='Council')) - is_nomination_period = timezone.now().date() < ROTM_NOMINATION_END_DATE + is_nomination_period = timezone.now().date() < rotm_nomination_end_date() data = {'pageuser': user, 'user_profile': user.userprofile, 'added_by': user.userprofile.added_by, diff --git a/remo/voting/tasks.py b/remo/voting/tasks.py index e2ec1a63b..6eb5f71cb 100644 --- a/remo/voting/tasks.py +++ b/remo/voting/tasks.py @@ -19,10 +19,13 @@ EXTEND_VOTING_PERIOD = 24 * 3600 # 24 hours NOTIFICATION_INTERVAL = 24 * 3600 # 24 hours -ROTM_NOMINATION_END_DATE = date(now().year, now().month, 10) ROTM_VOTING_DAYS = 14 +def rotm_nomination_end_date(): + return date(now().year, now().month, 10) + + @task def send_voting_mail(voting_id, subject, email_template): """Send to user_list emails based rendered using email_template @@ -129,12 +132,12 @@ def create_rotm_poll(): create_poll_flag = True poll_name = 'Rep of the month for {0}'.format(number2month(now().month)) - start = (datetime.combine(ROTM_NOMINATION_END_DATE, datetime.min.time()) + - timedelta(days=1)) + start = (datetime.combine(rotm_nomination_end_date(), + datetime.min.time()) + timedelta(days=1)) end = start + timedelta(days=ROTM_VOTING_DAYS) rotm_poll = Poll.objects.filter(name=poll_name, start=start, end=end) - if not now().date() > ROTM_NOMINATION_END_DATE or rotm_poll.exists(): + if not now().date() > rotm_nomination_end_date() or rotm_poll.exists(): create_poll_flag = False nominees = User.objects.filter(userprofile__registration_complete=True,