From 35e9a3a39f3e2785b86179e6c121d5203de08303 Mon Sep 17 00:00:00 2001 From: Moritz Schlarb Date: Sat, 19 May 2012 00:07:11 +0200 Subject: [PATCH] Show only public sheets/assignments to normal users, Issue #47 --- sauce/model/event.py | 16 ++++++++++++ sauce/templates/details.mak | 50 ++++++++++++++++++++++++++----------- sauce/templates/lists.mak | 5 ++++ 3 files changed, 57 insertions(+), 14 deletions(-) diff --git a/sauce/model/event.py b/sauce/model/event.py index 70272699..fb344259 100644 --- a/sauce/model/event.py +++ b/sauce/model/event.py @@ -59,6 +59,22 @@ def previous_sheets(self): def future_sheets(self): return [s for s in self.sheets if s.start_time > datetime.now()] + @property + def public_sheets(self): + return [s for s in self.sheets if s.public] + + @property + def current_public_sheets(self): + return [s for s in self.sheets if s.public and s.start_time < datetime.now() and s.end_time > datetime.now()] + + @property + def previous_public_sheets(self): + return [s for s in self.sheets if s.public and s.end_time < datetime.now()] + + @property + def future_public_sheets(self): + return [s for s in self.sheets if s.public and s.start_time > datetime.now()] + @property def url(self): return '/events/%s' % self._url diff --git a/sauce/templates/details.mak b/sauce/templates/details.mak index 08c61860..216713a2 100644 --- a/sauce/templates/details.mak +++ b/sauce/templates/details.mak @@ -20,25 +20,47 @@ ${times_dl(event)} % endif -% if event.sheets: -

Sheets

- - % if event.current_sheets: -

Current sheets

- ${lists.sheets(event.current_sheets)} - % endif +% if request.teacher: + % if event.sheets: +

Sheets

+ + % if event.current_sheets: +

Current sheets

+ ${lists.sheets(event.current_sheets)} + % endif - % if event.future_sheets: -

Future sheets

- ${lists.sheets_short(event.future_sheets)} - % endif + % if event.future_sheets: +

Future sheets

+ ${lists.sheets_short(event.future_sheets)} + % endif - % if event.previous_sheets: -

Previous sheets

- ${lists.sheets_short(event.previous_sheets)} + % if event.previous_sheets: +

Previous sheets

+ ${lists.sheets_short(event.previous_sheets)} + % endif % endif +% else: + + % if event.public_sheets: +

Sheets

+ % if event.current_sheets: +

Current sheets

+ ${lists.sheets(event.current_public_sheets)} + % endif + + % if event.future_sheets: +

Future sheets

+ ${lists.sheets_short(event.future_public_sheets)} + % endif + + % if event.previous_sheets: +

Previous sheets

+ ${lists.sheets_short(event.previous_public_sheets)} + % endif + % endif + % endif % if event.news: diff --git a/sauce/templates/lists.mak b/sauce/templates/lists.mak index 14d499c9..f2b18f5d 100644 --- a/sauce/templates/lists.mak +++ b/sauce/templates/lists.mak @@ -19,6 +19,11 @@ <%def name="assignments(assignments)"> +<% +if not request.teacher: + assignments = [a for a in assignments if a.public] +%> +
%for assignment in assignments:
${assignment.link}