summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
Diffstat (limited to 'program')
-rw-r--r--program/admin.py2
-rw-r--r--program/models.py1
-rw-r--r--program/views.py24
3 files changed, 15 insertions, 12 deletions
diff --git a/program/admin.py b/program/admin.py
index bdd3acc..87cceba 100644
--- a/program/admin.py
+++ b/program/admin.py
@@ -25,7 +25,6 @@ class ShowTopicAdmin(admin.ModelAdmin):
class NoteAdmin(admin.ModelAdmin):
date_hierarchy = 'start'
- exclude = ('owner',)
list_display = ('title', 'show', 'start', 'status')
list_filter = ('status',)
ordering = ('timeslot',)
@@ -42,7 +41,6 @@ class NoteAdmin(admin.ModelAdmin):
return super(NoteAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
def save_model(self, request, obj, form, change):
- obj.owner = request.user
obj.save()
class TimeSlotInline(admin.TabularInline):
diff --git a/program/models.py b/program/models.py
index 484c191..5ee4446 100644
--- a/program/models.py
+++ b/program/models.py
@@ -452,7 +452,6 @@ class Note(models.Model):
(2, _("Repetition")),
)
timeslot = models.OneToOneField(TimeSlot, verbose_name=_("Time slot"))
- owner = models.ForeignKey(User, related_name='notes', verbose_name=_("Owner"))
title = models.CharField(_("Title"), max_length=128)
content = tinymce_models.HTMLField(_("Content"))
status = models.IntegerField(_("Status"), choices=STATUS_CHOICES, default=1)
diff --git a/program/views.py b/program/views.py
index d824df8..0e86518 100644
--- a/program/views.py
+++ b/program/views.py
@@ -91,10 +91,9 @@ def current_show(request):
def week_schedule(request, year=None, week=None):
if year is None and week is None:
- year, week = datetime.strftime(datetime.today(), '%Y__%W').split('__')
-
- monday = datetime.strptime('%s__%s__1__06__00' % (year, week), '%Y__%W__%w__%H__%M')
+ year, week = datetime.strftime(datetime.now(), '%G__%V').split('__')
+ monday = tofirstdayinisoweek(int(year), int(week))
tuesday = monday+timedelta(days=1)
wednesday = monday+timedelta(days=2)
thursday = monday+timedelta(days=3)
@@ -114,12 +113,12 @@ def week_schedule(request, year=None, week=None):
extra_context['saturday_timeslots'] = TimeSlot.objects.get_day_timeslots(saturday)
extra_context['sunday_timeslots'] = TimeSlot.objects.get_day_timeslots(sunday)
- extra_context['last_w'] = datetime.strftime(monday-timedelta(days=7), '%Y/%W')
- extra_context['cur_w'] = '%s/%s' % (year, week)
- extra_context['next_w1'] = datetime.strftime(monday+timedelta(days=7), '%Y/%W')
- extra_context['next_w2'] = datetime.strftime(monday+timedelta(days=14), '%Y/%W')
- extra_context['next_w3'] = datetime.strftime(monday+timedelta(days=21), '%Y/%W')
- extra_context['next_w4'] = datetime.strftime(monday+timedelta(days=28), '%Y/%W')
+ extra_context['last_w'] = datetime.strftime(monday-timedelta(days=7), '%G/%V')
+ extra_context['cur_w'] = datetime.strftime(monday, '%G/%V')
+ extra_context['next_w1'] = datetime.strftime(monday+timedelta(days=7), '%G/%V')
+ extra_context['next_w2'] = datetime.strftime(monday+timedelta(days=14), '%G/%V')
+ extra_context['next_w3'] = datetime.strftime(monday+timedelta(days=21), '%G/%V')
+ extra_context['next_w4'] = datetime.strftime(monday+timedelta(days=28), '%G/%V')
return simple.direct_to_template(request, template='program/week_schedule.html', extra_context=extra_context)
@@ -148,3 +147,10 @@ def json_day_schedule(request, year=None, month=None, day=None):
schedule.append((ts.start.strftime('%H:%M:%S'), -1))
return HttpResponse(json.dumps(schedule), content_type="application/json")
+
+def tofirstdayinisoweek(year, week):
+ # http://stackoverflow.com/questions/5882405/get-date-from-iso-week-number-in-python
+ ret = datetime.strptime('%04d-%02d-1' % (year, week), '%Y-%W-%w')
+ if date(year, 1, 4).isoweekday() > 4:
+ ret -= timedelta(days=7)
+ return ret \ No newline at end of file