Fix bulletin timezones
This commit is contained in:
parent
0d44b8ec78
commit
487c2f3650
@ -56,9 +56,9 @@ def by_email(email):
|
||||
member.member_type = 1 # Ordinary Member
|
||||
|
||||
# Calculate expiration date
|
||||
member.expires = timezone.now().date().replace(month=3, day=31)
|
||||
member.expires = timezone.localtime(timezone.now()).date().replace(month=3, day=31)
|
||||
member.expires = member.expires.replace(year=member.expires.year+1)
|
||||
if member.expires < timezone.now().date(): # Add 1 year if after Mar 31, else add 2 years
|
||||
if member.expires < timezone.localtime(timezone.now()).date(): # Add 1 year if after Mar 31, else add 2 years
|
||||
member.expires = member.expires.replace(year=member.expires.year+1)
|
||||
|
||||
return member
|
||||
|
@ -182,9 +182,9 @@ def signup_save(request):
|
||||
member.member_type = 2 # Associate Member
|
||||
|
||||
# Calculate expiration date
|
||||
member.expires = timezone.now().date().replace(month=3, day=20)
|
||||
member.expires = timezone.localtime(timezone.now()).date().replace(month=3, day=20)
|
||||
member.expires = member.expires.replace(year=member.expires.year+1)
|
||||
if member.expires < timezone.now().date(): # Add 1 year if after Mar 20, else add 2 years
|
||||
if member.expires < timezone.localtime(timezone.now()).date(): # Add 1 year if after Mar 20, else add 2 years
|
||||
member.expires = member.expires.replace(year=member.expires.year+1)
|
||||
|
||||
errors = member.validation_problems()
|
||||
|
@ -91,9 +91,9 @@ class Command(BaseCommand):
|
||||
|
||||
client = boto3.client('ses', aws_access_key_id=settings.AWS_KEY_ID, aws_secret_access_key=settings.AWS_SECRET, region_name=settings.AWS_REGION)
|
||||
|
||||
title = '{} News: {}'.format(settings.ORG_NAME, timezone.now().strftime('%d %B %Y'))
|
||||
title = '{} News: {}'.format(settings.ORG_NAME, timezone.localtime(timezone.now()).strftime('%d %B %Y'))
|
||||
|
||||
calbegin, calend, bulbegin, bulend = sspromotions.utils.bulletin_dates(timezone.now())
|
||||
calbegin, calend, bulbegin, bulend = sspromotions.utils.bulletin_dates(timezone.localtime(timezone.now()))
|
||||
events = list(sspromotions.utils.get_calendar_events(calbegin, calend))
|
||||
|
||||
for member in members:
|
||||
|
@ -39,7 +39,7 @@ def bulletin_list(request):
|
||||
items_upcoming = []
|
||||
items_future = []
|
||||
|
||||
dtbegin = timezone.now().date()
|
||||
dtbegin = timezone.localtime(timezone.now()).date()
|
||||
dtend = dtbegin + datetime.timedelta(days=7)
|
||||
|
||||
for item in models.BulletinItem.objects.all():
|
||||
@ -70,12 +70,12 @@ def bulletin_preview(request):
|
||||
dt = datetime.datetime.strptime(request.POST['date'], '%Y-%m-%d')
|
||||
else:
|
||||
groups = models.Group.objects.all()
|
||||
dt = timezone.now() - datetime.timedelta(days=6)
|
||||
dt = timezone.localtime(timezone.now()) - datetime.timedelta(days=6)
|
||||
|
||||
calbegin, calend, bulbegin, bulend = utils.bulletin_dates(dt)
|
||||
return render(request, 'sspromotions/email/bulletin.html', utils.bulletin_args(None, groups, utils.get_calendar_events(calbegin, calend), bulbegin, bulend))
|
||||
else:
|
||||
date = timezone.now().date()
|
||||
date = timezone.localtime(timezone.now()).date()
|
||||
date += datetime.timedelta(days=(6 - date.weekday() + 7) % 7) # Next Sunday (6 = Sunday)
|
||||
return render(request, 'sspromotions/bulletin_preview.html', {'date': date, 'groups': models.Group.objects.filter(hidden=False).all()})
|
||||
|
||||
@ -101,7 +101,7 @@ def bulletin_new(request):
|
||||
else:
|
||||
item = models.BulletinItem()
|
||||
item.author = request.user
|
||||
item.date = timezone.now().date()
|
||||
item.date = timezone.localtime(timezone.now()).date()
|
||||
item.date += datetime.timedelta(days=(6 - item.date.weekday() + 7) % 7) # Next Sunday (6 = Sunday)
|
||||
return render(request, 'sspromotions/bulletin_edit.html', {
|
||||
'item': item,
|
||||
|
Loading…
Reference in New Issue
Block a user