Skip to content

Commit 4588617

Browse files
committed
Improve and rename function has_custom_time to has_irregular_time
1 parent 989ee1e commit 4588617

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

naucse/models.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,15 @@ def _session_time(self, key):
361361
return None
362362

363363
@reify
364-
def has_custom_time(self):
365-
session_start_time = self._session_time('start')
366-
session_end_time = self._session_time('end')
367-
368-
custom_start = session_start_time is not None \
369-
and self.course.default_start_time is not None \
370-
and session_start_time != self.course.default_start_time
371-
custom_end = session_end_time is not None \
372-
and self.course.default_end_time is not None \
373-
and session_end_time != self.course.default_end_time
374-
return custom_start or custom_end
364+
def has_irregular_time(self):
365+
"""True iff the session has its own start or end time, the course has
366+
a default start or end time, and either of those does not match."""
367+
368+
irregular_start = self.course.default_start_time is not None \
369+
and self._time(self.course.default_start_time) != self.start_time
370+
irregular_end = self.course.default_end_time is not None \
371+
and self._time(self.course.default_end_time) != self.end_time
372+
return irregular_start or irregular_end
375373

376374
@reify
377375
def start_time(self):

naucse/templates/course.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ <h4>
4040
</a>
4141
{% if session.date %}
4242
<small>({{ session.date | format_date -}}
43-
{%- if session.has_custom_time -%}
43+
{%- if session.has_irregular_time -%}
4444
, {{ session.start_time | format_time }}–{{ session.end_time | format_time -}}
4545
{% endif -%}
4646
)</small>
4747
{% endif %}
4848
</h4>
49-
{% if session.has_custom_time %}
49+
{% if session.has_irregular_time %}
5050
<div>{{ bytesize_icon('alert') }} Pozor, změna času!</div>
5151
{% endif %}
5252
{% if session.description %}{{ session.description | markdown }}{% endif %}

0 commit comments

Comments
 (0)