Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Commit

Permalink
Show only public sheets/assignments to normal users, Issue #47
Browse files Browse the repository at this point in the history
  • Loading branch information
moschlar committed May 18, 2012
1 parent 418ae4c commit 35e9a3a
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 14 deletions.
16 changes: 16 additions & 0 deletions sauce/model/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 36 additions & 14 deletions sauce/templates/details.mak
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,47 @@
${times_dl(event)}
% endif

% if event.sheets:
<h3>Sheets</h3>

% if event.current_sheets:
<h3>Current sheets</h3>
${lists.sheets(event.current_sheets)}
% endif
% if request.teacher:
% if event.sheets:
<h3>Sheets</h3>

% if event.current_sheets:
<h3>Current sheets</h3>
${lists.sheets(event.current_sheets)}
% endif

% if event.future_sheets:
<h3>Future sheets</h3>
${lists.sheets_short(event.future_sheets)}
% endif
% if event.future_sheets:
<h3>Future sheets</h3>
${lists.sheets_short(event.future_sheets)}
% endif

% if event.previous_sheets:
<h3>Previous sheets</h3>
${lists.sheets_short(event.previous_sheets)}
% if event.previous_sheets:
<h3>Previous sheets</h3>
${lists.sheets_short(event.previous_sheets)}
% endif
% endif

% else:

% if event.public_sheets:
<h3>Sheets</h3>

% if event.current_sheets:
<h3>Current sheets</h3>
${lists.sheets(event.current_public_sheets)}
% endif

% if event.future_sheets:
<h3>Future sheets</h3>
${lists.sheets_short(event.future_public_sheets)}
% endif

% if event.previous_sheets:
<h3>Previous sheets</h3>
${lists.sheets_short(event.previous_public_sheets)}
% endif
% endif

% endif

% if event.news:
Expand Down
5 changes: 5 additions & 0 deletions sauce/templates/lists.mak
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@

<%def name="assignments(assignments)">

<%
if not request.teacher:
assignments = [a for a in assignments if a.public]
%>

<dl>
%for assignment in assignments:
<dt>${assignment.link}</dt>
Expand Down

0 comments on commit 35e9a3a

Please sign in to comment.