utils
— Swingtime Utilities¶
Common features and functions for swingtime
Functions¶
html_mark_safe
¶
-
utils.
html_mark_safe
(func)¶ Decorator for functions return strings that should be treated as template safe.
time_delta_total_seconds
¶
-
utils.
time_delta_total_seconds
(time_delta)¶ Calculate the total number of seconds represented by a
datetime.timedelta
object
month_boundaries
¶
-
utils.
month_boundaries
([dt=None])¶ Return a 2-tuple containing the datetime instances for the first and last dates of the current month or using
dt
as a reference.
css_class_cycler
¶
create_timeslot_table
¶
-
utils.
create_timeslot_table
([dt=None, items=None, start_time=swingtime_settings.TIMESLOT_START_TIME, end_time_delta=swingtime_settings.TIMESLOT_END_TIME_DURATION, time_delta=swingtime_settings.TIMESLOT_INTERVAL, min_columns=swingtime_settings.TIMESLOT_MIN_COLUMNS, css_class_cycles=css_class_cycler, proxy_class=DefaultOccurrenceProxy])¶ Create a grid-like object representing a sequence of times (rows) and columns where cells are either empty or reference a wrapper object for event occasions that overlap a specific time slot.
Currently, there is an assumption that if an occurrence has a
start_time
that falls with the temporal scope of the grid, then thatstart_time
will also match an interval in the sequence of the computed row entries.dt
- a
datetime.datetime
instance orNone
to default to now items
- a queryset or sequence of
Occurrence
instances. IfNone
, default to the daily occurrences fordt
start_time
- a
datetime.time
instance, defaulting toswingtime_settings.TIMESLOT_START_TIME
end_time_delta
- a
datetime.timedelta
instance, defaulting toswingtime_settings.TIMESLOT_END_TIME_DURATION
time_delta
- a
datetime.timedelta
instance, defaulting toswingtime_settings.TIMESLOT_INTERVAL
min_column
- the minimum number of columns to show in the table, defaulting to
swingtime_settings.TIMESLOT_MIN_COLUMNS
css_class_cycles
- if not
None
, a callable returning a dictionary keyed by desiredEventType
abbreviations with values that iterate over progressive CSS class names for the particular abbreviation; defaults tocss_class_cycler()
proxy_class
- a wrapper class for accessing an
Occurrence
object, which should also exposeevent_type
andevent_class
attrs, and handle the custom output via its __unicode__ method; defaults toDefaultOccurrenceProxy
Classes¶
BaseOccurrenceProxy
¶
-
class
utils.
BaseOccurrenceProxy
(object)¶ A simple wrapper class for handling the representational aspects of an
Occurrence
instance.
DefaultOccurrenceProxy
¶
-
class
utils.
DefaultOccurrenceProxy
(BaseOccurrenceProxy)¶ Through the
__unicode__
method, outputs a safe string anchor tag for theOccurrence
instance, followed by simple token placeholders to represent additional slot fillings.