repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
tjcsl/ion
intranet/apps/eighth/models.py
EighthBlock.attendance_locked
def attendance_locked(self): """Is it past 10PM on the day of the block?""" now = datetime.datetime.now() return now.date() > self.date or (now.date() == self.date and now.time() > datetime.time(settings.ATTENDANCE_LOCK_HOUR, 0))
python
def attendance_locked(self): """Is it past 10PM on the day of the block?""" now = datetime.datetime.now() return now.date() > self.date or (now.date() == self.date and now.time() > datetime.time(settings.ATTENDANCE_LOCK_HOUR, 0))
Is it past 10PM on the day of the block?
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L570-L573
tjcsl/ion
intranet/apps/eighth/models.py
EighthBlock.num_signups
def num_signups(self): """How many people have signed up?""" return EighthSignup.objects.filter(scheduled_activity__block=self, user__in=User.objects.get_students()).count()
python
def num_signups(self): """How many people have signed up?""" return EighthSignup.objects.filter(scheduled_activity__block=self, user__in=User.objects.get_students()).count()
How many people have signed up?
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L575-L577
tjcsl/ion
intranet/apps/eighth/models.py
EighthBlock.num_no_signups
def num_no_signups(self): """How many people have not signed up?""" signup_users_count = User.objects.get_students().count() return signup_users_count - self.num_signups()
python
def num_no_signups(self): """How many people have not signed up?""" signup_users_count = User.objects.get_students().count() return signup_users_count - self.num_signups()
How many people have not signed up?
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L579-L582
tjcsl/ion
intranet/apps/eighth/models.py
EighthBlock.get_hidden_signups
def get_hidden_signups(self): """ Return a list of Users who are *not* in the All Students list but have signed up for an activity. This is usually a list of signups for z-Withdrawn from TJ """ return EighthSignup.objects.filter(scheduled_activity__block=self).exclude(user__in=User.objects.g...
python
def get_hidden_signups(self): """ Return a list of Users who are *not* in the All Students list but have signed up for an activity. This is usually a list of signups for z-Withdrawn from TJ """ return EighthSignup.objects.filter(scheduled_activity__block=self).exclude(user__in=User.objects.g...
Return a list of Users who are *not* in the All Students list but have signed up for an activity. This is usually a list of signups for z-Withdrawn from TJ
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L588-L591
tjcsl/ion
intranet/apps/eighth/models.py
EighthBlock.is_this_year
def is_this_year(self): """Return whether the block occurs after September 1st of this school year.""" return is_current_year(datetime.datetime.combine(self.date, datetime.time()))
python
def is_this_year(self): """Return whether the block occurs after September 1st of this school year.""" return is_current_year(datetime.datetime.combine(self.date, datetime.time()))
Return whether the block occurs after September 1st of this school year.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L612-L614
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivityManager.for_sponsor
def for_sponsor(self, sponsor, include_cancelled=False): """Return a QueryList of EighthScheduledActivities where the given EighthSponsor is sponsoring. If a sponsorship is defined in an EighthActivity, it may be overridden on a block by block basis in an EighthScheduledActivity. Sponso...
python
def for_sponsor(self, sponsor, include_cancelled=False): """Return a QueryList of EighthScheduledActivities where the given EighthSponsor is sponsoring. If a sponsorship is defined in an EighthActivity, it may be overridden on a block by block basis in an EighthScheduledActivity. Sponso...
Return a QueryList of EighthScheduledActivities where the given EighthSponsor is sponsoring. If a sponsorship is defined in an EighthActivity, it may be overridden on a block by block basis in an EighthScheduledActivity. Sponsors from the EighthActivity do not carry over. Eight...
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L631-L648
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.full_title
def full_title(self): """Gets the full title for the activity, appending the title of the scheduled activity to the activity's name.""" cancelled_str = " (Cancelled)" if self.cancelled else "" act_name = self.activity.name + cancelled_str if self.special and not self.activity.spe...
python
def full_title(self): """Gets the full title for the activity, appending the title of the scheduled activity to the activity's name.""" cancelled_str = " (Cancelled)" if self.cancelled else "" act_name = self.activity.name + cancelled_str if self.special and not self.activity.spe...
Gets the full title for the activity, appending the title of the scheduled activity to the activity's name.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L728-L735
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.title_with_flags
def title_with_flags(self): """Gets the title for the activity, appending the title of the scheduled activity to the activity's name and flags.""" cancelled_str = " (Cancelled)" if self.cancelled else "" name_with_flags = self.activity._name_with_flags(True, self.title) + cancelled_str ...
python
def title_with_flags(self): """Gets the title for the activity, appending the title of the scheduled activity to the activity's name and flags.""" cancelled_str = " (Cancelled)" if self.cancelled else "" name_with_flags = self.activity._name_with_flags(True, self.title) + cancelled_str ...
Gets the title for the activity, appending the title of the scheduled activity to the activity's name and flags.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L738-L745
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.get_true_sponsors
def get_true_sponsors(self): """Get the sponsors for the scheduled activity, taking into account activity defaults and overrides.""" sponsors = self.sponsors.all() if len(sponsors) > 0: return sponsors else: return self.activity.sponsors.all()
python
def get_true_sponsors(self): """Get the sponsors for the scheduled activity, taking into account activity defaults and overrides.""" sponsors = self.sponsors.all() if len(sponsors) > 0: return sponsors else: return self.activity.sponsors.all()
Get the sponsors for the scheduled activity, taking into account activity defaults and overrides.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L747-L755
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.user_is_sponsor
def user_is_sponsor(self, user): """Return whether the given user is a sponsor of the activity. Returns: Boolean """ sponsors = self.get_true_sponsors() for sponsor in sponsors: sp_user = sponsor.user if sp_user == user: retur...
python
def user_is_sponsor(self, user): """Return whether the given user is a sponsor of the activity. Returns: Boolean """ sponsors = self.get_true_sponsors() for sponsor in sponsors: sp_user = sponsor.user if sp_user == user: retur...
Return whether the given user is a sponsor of the activity. Returns: Boolean
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L757-L770
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.get_true_rooms
def get_true_rooms(self): """Get the rooms for the scheduled activity, taking into account activity defaults and overrides.""" rooms = self.rooms.all() if len(rooms) > 0: return rooms else: return self.activity.rooms.all()
python
def get_true_rooms(self): """Get the rooms for the scheduled activity, taking into account activity defaults and overrides.""" rooms = self.rooms.all() if len(rooms) > 0: return rooms else: return self.activity.rooms.all()
Get the rooms for the scheduled activity, taking into account activity defaults and overrides.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L772-L780
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.get_true_capacity
def get_true_capacity(self): """Get the capacity for the scheduled activity, taking into account activity defaults and overrides.""" c = self.capacity if c is not None: return c else: if self.rooms.count() == 0 and self.activity.default_capacity: ...
python
def get_true_capacity(self): """Get the capacity for the scheduled activity, taking into account activity defaults and overrides.""" c = self.capacity if c is not None: return c else: if self.rooms.count() == 0 and self.activity.default_capacity: ...
Get the capacity for the scheduled activity, taking into account activity defaults and overrides.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L782-L795
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.is_full
def is_full(self): """Return whether the activity is full.""" capacity = self.get_true_capacity() if capacity != -1: num_signed_up = self.eighthsignup_set.count() return num_signed_up >= capacity return False
python
def is_full(self): """Return whether the activity is full.""" capacity = self.get_true_capacity() if capacity != -1: num_signed_up = self.eighthsignup_set.count() return num_signed_up >= capacity return False
Return whether the activity is full.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L838-L844
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.is_almost_full
def is_almost_full(self): """Return whether the activity is almost full (>90%).""" capacity = self.get_true_capacity() if capacity != -1: num_signed_up = self.eighthsignup_set.count() return num_signed_up >= (0.9 * capacity) return False
python
def is_almost_full(self): """Return whether the activity is almost full (>90%).""" capacity = self.get_true_capacity() if capacity != -1: num_signed_up = self.eighthsignup_set.count() return num_signed_up >= (0.9 * capacity) return False
Return whether the activity is almost full (>90%).
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L846-L852
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.is_overbooked
def is_overbooked(self): """Return whether the activity is overbooked.""" capacity = self.get_true_capacity() if capacity != -1: num_signed_up = self.eighthsignup_set.count() return num_signed_up > capacity return False
python
def is_overbooked(self): """Return whether the activity is overbooked.""" capacity = self.get_true_capacity() if capacity != -1: num_signed_up = self.eighthsignup_set.count() return num_signed_up > capacity return False
Return whether the activity is overbooked.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L854-L860
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.is_too_early_to_signup
def is_too_early_to_signup(self, now=None): """Return whether it is too early to sign up for the activity if it is a presign (48 hour logic is here).""" if now is None: now = datetime.datetime.now() activity_date = (datetime.datetime.combine(self.block.date, datetime.time(0,...
python
def is_too_early_to_signup(self, now=None): """Return whether it is too early to sign up for the activity if it is a presign (48 hour logic is here).""" if now is None: now = datetime.datetime.now() activity_date = (datetime.datetime.combine(self.block.date, datetime.time(0,...
Return whether it is too early to sign up for the activity if it is a presign (48 hour logic is here).
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L862-L872
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.get_viewable_members
def get_viewable_members(self, user=None): """Get the list of members that you have permissions to view. Returns: List of members """ members = [] for member in self.members.all(): show = False if member.can_view_eighth: show = member.can...
python
def get_viewable_members(self, user=None): """Get the list of members that you have permissions to view. Returns: List of members """ members = [] for member in self.members.all(): show = False if member.can_view_eighth: show = member.can...
Get the list of members that you have permissions to view. Returns: List of members
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L878-L900
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.get_viewable_members_serializer
def get_viewable_members_serializer(self, request): """Get a QuerySet of User objects of students in the activity. Needed for the EighthScheduledActivitySerializer. Returns: QuerySet """ ids = [] user = request.user for member in self.members.all(): ...
python
def get_viewable_members_serializer(self, request): """Get a QuerySet of User objects of students in the activity. Needed for the EighthScheduledActivitySerializer. Returns: QuerySet """ ids = [] user = request.user for member in self.members.all(): ...
Get a QuerySet of User objects of students in the activity. Needed for the EighthScheduledActivitySerializer. Returns: QuerySet
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L902-L926
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.get_hidden_members
def get_hidden_members(self, user=None): """Get the members that you do not have permission to view. Returns: List of members hidden based on their permission preferences """ hidden_members = [] for member in self.members.all(): show = False if member.ca...
python
def get_hidden_members(self, user=None): """Get the members that you do not have permission to view. Returns: List of members hidden based on their permission preferences """ hidden_members = [] for member in self.members.all(): show = False if member.ca...
Get the members that you do not have permission to view. Returns: List of members hidden based on their permission preferences
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L928-L950
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.get_both_blocks_sibling
def get_both_blocks_sibling(self): """If this is a both-blocks activity, get the other EighthScheduledActivity object that occurs on the other block. both_blocks means A and B block, NOT all of the blocks on that day. Returns: EighthScheduledActivity object if ...
python
def get_both_blocks_sibling(self): """If this is a both-blocks activity, get the other EighthScheduledActivity object that occurs on the other block. both_blocks means A and B block, NOT all of the blocks on that day. Returns: EighthScheduledActivity object if ...
If this is a both-blocks activity, get the other EighthScheduledActivity object that occurs on the other block. both_blocks means A and B block, NOT all of the blocks on that day. Returns: EighthScheduledActivity object if found None if the activity can...
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L952-L979
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.add_user
def add_user(self, user, request=None, force=False, no_after_deadline=False, add_to_waitlist=False): """Sign up a user to this scheduled activity if possible. This is where the magic happens. Raises an exception if there's a problem signing the user up unless the signup is forced. """ ...
python
def add_user(self, user, request=None, force=False, no_after_deadline=False, add_to_waitlist=False): """Sign up a user to this scheduled activity if possible. This is where the magic happens. Raises an exception if there's a problem signing the user up unless the signup is forced. """ ...
Sign up a user to this scheduled activity if possible. This is where the magic happens. Raises an exception if there's a problem signing the user up unless the signup is forced.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L987-L1216
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.cancel
def cancel(self): """Cancel an EighthScheduledActivity. This does nothing besides set the cancelled flag and save the object. """ # super(EighthScheduledActivity, self).save(*args, **kwargs) logger.debug("Running cancel hooks: {}".format(self)) if not self.can...
python
def cancel(self): """Cancel an EighthScheduledActivity. This does nothing besides set the cancelled flag and save the object. """ # super(EighthScheduledActivity, self).save(*args, **kwargs) logger.debug("Running cancel hooks: {}".format(self)) if not self.can...
Cancel an EighthScheduledActivity. This does nothing besides set the cancelled flag and save the object.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L1218-L1246
tjcsl/ion
intranet/apps/eighth/models.py
EighthScheduledActivity.uncancel
def uncancel(self): """Uncancel an EighthScheduledActivity. This does nothing besides unset the cancelled flag and save the object. """ if self.cancelled: logger.debug("Uncancelling {}".format(self)) self.cancelled = False self.save() # ...
python
def uncancel(self): """Uncancel an EighthScheduledActivity. This does nothing besides unset the cancelled flag and save the object. """ if self.cancelled: logger.debug("Uncancelling {}".format(self)) self.cancelled = False self.save() # ...
Uncancel an EighthScheduledActivity. This does nothing besides unset the cancelled flag and save the object.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L1248-L1271
tjcsl/ion
intranet/apps/eighth/models.py
EighthSignup.validate_unique
def validate_unique(self, *args, **kwargs): """Checked whether more than one EighthSignup exists for a User on a given EighthBlock.""" super(EighthSignup, self).validate_unique(*args, **kwargs) if self.has_conflict(): raise ValidationError({NON_FIELD_ERRORS: ("EighthSignup already e...
python
def validate_unique(self, *args, **kwargs): """Checked whether more than one EighthSignup exists for a User on a given EighthBlock.""" super(EighthSignup, self).validate_unique(*args, **kwargs) if self.has_conflict(): raise ValidationError({NON_FIELD_ERRORS: ("EighthSignup already e...
Checked whether more than one EighthSignup exists for a User on a given EighthBlock.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L1355-L1360
tjcsl/ion
intranet/apps/eighth/models.py
EighthSignup.remove_signup
def remove_signup(self, user=None, force=False, dont_run_waitlist=False): """Attempt to remove the EighthSignup if the user has permission to do so.""" exception = eighth_exceptions.SignupException() if user is not None: if user != self.user and not user.is_eighth_admin: ...
python
def remove_signup(self, user=None, force=False, dont_run_waitlist=False): """Attempt to remove the EighthSignup if the user has permission to do so.""" exception = eighth_exceptions.SignupException() if user is not None: if user != self.user and not user.is_eighth_admin: ...
Attempt to remove the EighthSignup if the user has permission to do so.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/models.py#L1367-L1401
tjcsl/ion
intranet/apps/eighth/views/admin/scheduling.py
transfer_students_action
def transfer_students_action(request): """Do the actual process of transferring students.""" if "source_act" in request.GET: source_act = EighthScheduledActivity.objects.get(id=request.GET.get("source_act")) elif "source_act" in request.POST: source_act = EighthScheduledActivity.objects.get(...
python
def transfer_students_action(request): """Do the actual process of transferring students.""" if "source_act" in request.GET: source_act = EighthScheduledActivity.objects.get(id=request.GET.get("source_act")) elif "source_act" in request.POST: source_act = EighthScheduledActivity.objects.get(...
Do the actual process of transferring students.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/views/admin/scheduling.py#L369-L407
tjcsl/ion
intranet/apps/eighth/context_processors.py
start_date
def start_date(request): """Add the start date to the context for eighth admin views.""" if request.user and request.user.is_authenticated and request.user.is_eighth_admin: return {"admin_start_date": get_start_date(request)} return {}
python
def start_date(request): """Add the start date to the context for eighth admin views.""" if request.user and request.user.is_authenticated and request.user.is_eighth_admin: return {"admin_start_date": get_start_date(request)} return {}
Add the start date to the context for eighth admin views.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/context_processors.py#L7-L13
tjcsl/ion
intranet/apps/eighth/context_processors.py
absence_count
def absence_count(request): """Add the absence count to the context for students.""" if request.user and request.user.is_authenticated and request.user.is_student: absence_info = request.user.absence_info() num_absences = absence_info.count() show_notif = False if num_absences >...
python
def absence_count(request): """Add the absence count to the context for students.""" if request.user and request.user.is_authenticated and request.user.is_student: absence_info = request.user.absence_info() num_absences = absence_info.count() show_notif = False if num_absences >...
Add the absence count to the context for students.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/context_processors.py#L20-L39
tjcsl/ion
intranet/apps/files/models.py
HostManager.visible_to_user
def visible_to_user(self, user): """Get a list of hosts available to a given user. Same logic as Announcements and Events. """ return Host.objects.filter(Q(groups_visible__in=user.groups.all()) | Q(groups_visible__isnull=True)).distinct()
python
def visible_to_user(self, user): """Get a list of hosts available to a given user. Same logic as Announcements and Events. """ return Host.objects.filter(Q(groups_visible__in=user.groups.all()) | Q(groups_visible__isnull=True)).distinct()
Get a list of hosts available to a given user. Same logic as Announcements and Events.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/files/models.py#L45-L52
tjcsl/ion
intranet/apps/schedule/models.py
DayManager.get_future_days
def get_future_days(self): """Return only future Day objects.""" today = timezone.now().date() return Day.objects.filter(date__gte=today)
python
def get_future_days(self): """Return only future Day objects.""" today = timezone.now().date() return Day.objects.filter(date__gte=today)
Return only future Day objects.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/schedule/models.py#L108-L112
tjcsl/ion
intranet/apps/schedule/models.py
DayManager.today
def today(self): """Return the Day for the current day""" today = timezone.now().date() try: return Day.objects.get(date=today) except Day.DoesNotExist: return None
python
def today(self): """Return the Day for the current day""" today = timezone.now().date() try: return Day.objects.get(date=today) except Day.DoesNotExist: return None
Return the Day for the current day
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/schedule/models.py#L114-L120
tjcsl/ion
intranet/utils/date.py
get_date_range_this_year
def get_date_range_this_year(now=None): """Return the starting and ending date of the current school year.""" if now is None: now = datetime.datetime.now().date() if now.month <= settings.YEAR_TURNOVER_MONTH: date_start = datetime.datetime(now.year - 1, 8, 1) # TODO; don't hardcode these va...
python
def get_date_range_this_year(now=None): """Return the starting and ending date of the current school year.""" if now is None: now = datetime.datetime.now().date() if now.month <= settings.YEAR_TURNOVER_MONTH: date_start = datetime.datetime(now.year - 1, 8, 1) # TODO; don't hardcode these va...
Return the starting and ending date of the current school year.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/utils/date.py#L13-L23
tjcsl/ion
intranet/apps/users/templatetags/users.py
user_attr
def user_attr(username, attribute): """Gets an attribute of the user with the given username.""" return getattr(User.objects.get(username=username), attribute)
python
def user_attr(username, attribute): """Gets an attribute of the user with the given username.""" return getattr(User.objects.get(username=username), attribute)
Gets an attribute of the user with the given username.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/users/templatetags/users.py#L15-L17
tjcsl/ion
intranet/apps/users/templatetags/users.py
argument_request_user
def argument_request_user(obj, func_name): """Pass request.user as an argument to the given function call.""" func = getattr(obj, func_name) request = threadlocals.request() if request: return func(request.user)
python
def argument_request_user(obj, func_name): """Pass request.user as an argument to the given function call.""" func = getattr(obj, func_name) request = threadlocals.request() if request: return func(request.user)
Pass request.user as an argument to the given function call.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/users/templatetags/users.py#L21-L26
tjcsl/ion
intranet/apps/emailfwd/views.py
senior_email_forward_view
def senior_email_forward_view(request): """Add a forwarding address for graduating seniors.""" if not request.user.is_senior: messages.error(request, "Only seniors can set their forwarding address.") return redirect("index") try: forward = SeniorEmailForward.objects.get(user=request....
python
def senior_email_forward_view(request): """Add a forwarding address for graduating seniors.""" if not request.user.is_senior: messages.error(request, "Only seniors can set their forwarding address.") return redirect("index") try: forward = SeniorEmailForward.objects.get(user=request....
Add a forwarding address for graduating seniors.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/emailfwd/views.py#L14-L43
tjcsl/ion
intranet/apps/users/templatetags/phone_numbers.py
dashes
def dashes(phone): """Returns the phone number formatted with dashes.""" if isinstance(phone, str): if phone.startswith("+1"): return "1-" + "-".join((phone[2:5], phone[5:8], phone[8:])) elif len(phone) == 10: return "-".join((phone[:3], phone[3:6], phone[6:])) el...
python
def dashes(phone): """Returns the phone number formatted with dashes.""" if isinstance(phone, str): if phone.startswith("+1"): return "1-" + "-".join((phone[2:5], phone[5:8], phone[8:])) elif len(phone) == 10: return "-".join((phone[:3], phone[3:6], phone[6:])) el...
Returns the phone number formatted with dashes.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/users/templatetags/phone_numbers.py#L9-L19
tjcsl/ion
intranet/apps/signage/models.py
Page.deploy_to
def deploy_to(self, displays=None, exclude=[], lock=[]): """ Deploys page to listed display (specify with display). If display is None, deploy to all display. Can specify exclude for which display to exclude. This overwrites the first argument. """ if displays is None: ...
python
def deploy_to(self, displays=None, exclude=[], lock=[]): """ Deploys page to listed display (specify with display). If display is None, deploy to all display. Can specify exclude for which display to exclude. This overwrites the first argument. """ if displays is None: ...
Deploys page to listed display (specify with display). If display is None, deploy to all display. Can specify exclude for which display to exclude. This overwrites the first argument.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/signage/models.py#L34-L46
tjcsl/ion
intranet/apps/emerg/views.py
check_emerg
def check_emerg(): """Fetch from FCPS' emergency announcement page. URL defined in settings.FCPS_EMERGENCY_PAGE Request timeout defined in settings.FCPS_EMERGENCY_TIMEOUT """ status = True message = None if settings.EMERGENCY_MESSAGE: return True, settings.EMERGENCY_MESSAGE if...
python
def check_emerg(): """Fetch from FCPS' emergency announcement page. URL defined in settings.FCPS_EMERGENCY_PAGE Request timeout defined in settings.FCPS_EMERGENCY_TIMEOUT """ status = True message = None if settings.EMERGENCY_MESSAGE: return True, settings.EMERGENCY_MESSAGE if...
Fetch from FCPS' emergency announcement page. URL defined in settings.FCPS_EMERGENCY_PAGE Request timeout defined in settings.FCPS_EMERGENCY_TIMEOUT
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/emerg/views.py#L16-L63
tjcsl/ion
intranet/apps/emerg/views.py
get_emerg
def get_emerg(): """Get the cached FCPS emergency page, or check it again. Timeout defined in settings.CACHE_AGE["emerg"] """ key = "emerg:{}".format(datetime.datetime.now().date()) cached = cache.get(key) cached = None # Remove this for production if cached: logger.debug("Returni...
python
def get_emerg(): """Get the cached FCPS emergency page, or check it again. Timeout defined in settings.CACHE_AGE["emerg"] """ key = "emerg:{}".format(datetime.datetime.now().date()) cached = cache.get(key) cached = None # Remove this for production if cached: logger.debug("Returni...
Get the cached FCPS emergency page, or check it again. Timeout defined in settings.CACHE_AGE["emerg"]
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/emerg/views.py#L73-L88
tjcsl/ion
intranet/apps/auth/views.py
get_login_theme
def get_login_theme(): """Load a custom login theme (e.g. snow)""" today = datetime.now().date() if today.month == 12 or today.month == 1: # Snow return {"js": "themes/snow/snow.js", "css": "themes/snow/snow.css"} if today.month == 3 and (14 <= today.day <= 16): return {"js": "t...
python
def get_login_theme(): """Load a custom login theme (e.g. snow)""" today = datetime.now().date() if today.month == 12 or today.month == 1: # Snow return {"js": "themes/snow/snow.js", "css": "themes/snow/snow.css"} if today.month == 3 and (14 <= today.day <= 16): return {"js": "t...
Load a custom login theme (e.g. snow)
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/auth/views.py#L76-L86
tjcsl/ion
intranet/apps/auth/views.py
index_view
def index_view(request, auth_form=None, force_login=False, added_context=None): """Process and show the main login page or dashboard if logged in.""" if request.user.is_authenticated and not force_login: return dashboard_view(request) else: auth_form = auth_form or AuthenticateForm() ...
python
def index_view(request, auth_form=None, force_login=False, added_context=None): """Process and show the main login page or dashboard if logged in.""" if request.user.is_authenticated and not force_login: return dashboard_view(request) else: auth_form = auth_form or AuthenticateForm() ...
Process and show the main login page or dashboard if logged in.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/auth/views.py#L110-L153
tjcsl/ion
intranet/apps/auth/views.py
logout_view
def logout_view(request): """Clear the Kerberos cache and logout.""" do_logout(request) app_redirects = {"collegerecs": "https://apps.tjhsst.edu/collegerecs/logout?ion_logout=1"} app = request.GET.get("app", "") if app and app in app_redirects: return redirect(app_redirects[app]) retur...
python
def logout_view(request): """Clear the Kerberos cache and logout.""" do_logout(request) app_redirects = {"collegerecs": "https://apps.tjhsst.edu/collegerecs/logout?ion_logout=1"} app = request.GET.get("app", "") if app and app in app_redirects: return redirect(app_redirects[app]) retur...
Clear the Kerberos cache and logout.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/auth/views.py#L232-L241
tjcsl/ion
intranet/apps/auth/views.py
LoginView.post
def post(self, request): """Validate and process the login POST request.""" """Before September 1st, do not allow Class of [year+4] to log in.""" if request.POST.get("username", "").startswith(str(date.today().year + 4)) and date.today() < settings.SCHOOL_START_DATE: return index_vie...
python
def post(self, request): """Validate and process the login POST request.""" """Before September 1st, do not allow Class of [year+4] to log in.""" if request.POST.get("username", "").startswith(str(date.today().year + 4)) and date.today() < settings.SCHOOL_START_DATE: return index_vie...
Validate and process the login POST request.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/auth/views.py#L160-L214
tjcsl/ion
intranet/apps/schedule/views.py
do_default_fill
def do_default_fill(request): """Change all Mondays to 'Anchor Day' Change all Tuesday/Thursdays to 'Blue Day' Change all Wednesday/Fridays to 'Red Day'.""" monday = 0 tuesday = 1 wednesday = 2 thursday = 3 friday = 4 try: anchor_day = DayType.objects.get(name="Anchor Day") ...
python
def do_default_fill(request): """Change all Mondays to 'Anchor Day' Change all Tuesday/Thursdays to 'Blue Day' Change all Wednesday/Fridays to 'Red Day'.""" monday = 0 tuesday = 1 wednesday = 2 thursday = 3 friday = 4 try: anchor_day = DayType.objects.get(name="Anchor Day") ...
Change all Mondays to 'Anchor Day' Change all Tuesday/Thursdays to 'Blue Day' Change all Wednesday/Fridays to 'Red Day'.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/schedule/views.py#L225-L266
agoragames/kairos
kairos/mongo_backend.py
MongoBackend._unescape
def _unescape(self, value): ''' Recursively unescape values. Though slower, this doesn't require the user to know anything about the escaping when writing their own custom fetch functions. ''' if isinstance(value, (str,unicode)): return value.replace(self._escape_character, '.') elif isins...
python
def _unescape(self, value): ''' Recursively unescape values. Though slower, this doesn't require the user to know anything about the escaping when writing their own custom fetch functions. ''' if isinstance(value, (str,unicode)): return value.replace(self._escape_character, '.') elif isins...
Recursively unescape values. Though slower, this doesn't require the user to know anything about the escaping when writing their own custom fetch functions.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/mongo_backend.py#L90-L101
agoragames/kairos
kairos/mongo_backend.py
MongoBackend._batch_key
def _batch_key(self, query): ''' Get a unique id from a query. ''' return ''.join( ['%s%s'%(k,v) for k,v in sorted(query.items())] )
python
def _batch_key(self, query): ''' Get a unique id from a query. ''' return ''.join( ['%s%s'%(k,v) for k,v in sorted(query.items())] )
Get a unique id from a query.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/mongo_backend.py#L121-L125
agoragames/kairos
kairos/mongo_backend.py
MongoBackend._batch_insert
def _batch_insert(self, inserts, intervals, **kwargs): ''' Batch insert implementation. ''' updates = {} # TODO support flush interval for interval,config in self._intervals.items(): for timestamp,names in inserts.iteritems(): timestamps = self._normalize_timestamps(timestamp, inte...
python
def _batch_insert(self, inserts, intervals, **kwargs): ''' Batch insert implementation. ''' updates = {} # TODO support flush interval for interval,config in self._intervals.items(): for timestamp,names in inserts.iteritems(): timestamps = self._normalize_timestamps(timestamp, inte...
Batch insert implementation.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/mongo_backend.py#L127-L150
agoragames/kairos
kairos/mongo_backend.py
MongoBackend._insert
def _insert(self, name, value, timestamp, intervals, **kwargs): ''' Insert the new value. ''' # TODO: confirm that this is in fact using the indices correctly. for interval,config in self._intervals.items(): timestamps = self._normalize_timestamps(timestamp, intervals, config) for tstamp...
python
def _insert(self, name, value, timestamp, intervals, **kwargs): ''' Insert the new value. ''' # TODO: confirm that this is in fact using the indices correctly. for interval,config in self._intervals.items(): timestamps = self._normalize_timestamps(timestamp, intervals, config) for tstamp...
Insert the new value.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/mongo_backend.py#L152-L160
agoragames/kairos
kairos/mongo_backend.py
MongoBackend._insert_data
def _insert_data(self, name, value, timestamp, interval, config, **kwargs): '''Helper to insert data into mongo.''' # Mongo does not allow mixing atomic modifiers and non-$set sets in the # same update, so the choice is to either run the first upsert on # {'_id':id} to ensure the record is in place foll...
python
def _insert_data(self, name, value, timestamp, interval, config, **kwargs): '''Helper to insert data into mongo.''' # Mongo does not allow mixing atomic modifiers and non-$set sets in the # same update, so the choice is to either run the first upsert on # {'_id':id} to ensure the record is in place foll...
Helper to insert data into mongo.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/mongo_backend.py#L162-L203
agoragames/kairos
kairos/mongo_backend.py
MongoBackend._get
def _get(self, name, interval, config, timestamp, **kws): ''' Get the interval. ''' i_bucket = config['i_calc'].to_bucket(timestamp) fetch = kws.get('fetch') process_row = kws.get('process_row') or self._process_row rval = OrderedDict() query = {'name':name, 'interval':i_bucket} if ...
python
def _get(self, name, interval, config, timestamp, **kws): ''' Get the interval. ''' i_bucket = config['i_calc'].to_bucket(timestamp) fetch = kws.get('fetch') process_row = kws.get('process_row') or self._process_row rval = OrderedDict() query = {'name':name, 'interval':i_bucket} if ...
Get the interval.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/mongo_backend.py#L205-L238
agoragames/kairos
kairos/mongo_backend.py
MongoBackend._series
def _series(self, name, interval, config, buckets, **kws): ''' Fetch a series of buckets. ''' # make a copy of the buckets because we're going to mutate it buckets = list(buckets) rval = OrderedDict() step = config['step'] resolution = config.get('resolution',step) fetch = kws.get('f...
python
def _series(self, name, interval, config, buckets, **kws): ''' Fetch a series of buckets. ''' # make a copy of the buckets because we're going to mutate it buckets = list(buckets) rval = OrderedDict() step = config['step'] resolution = config.get('resolution',step) fetch = kws.get('f...
Fetch a series of buckets.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/mongo_backend.py#L240-L279
agoragames/kairos
kairos/mongo_backend.py
MongoBackend.delete
def delete(self, name): ''' Delete time series by name across all intervals. Returns the number of records deleted. ''' # TODO: confirm that this does not use the combo index and determine # performance implications. num_deleted = 0 for interval,config in self._intervals.items(): #...
python
def delete(self, name): ''' Delete time series by name across all intervals. Returns the number of records deleted. ''' # TODO: confirm that this does not use the combo index and determine # performance implications. num_deleted = 0 for interval,config in self._intervals.items(): #...
Delete time series by name across all intervals. Returns the number of records deleted.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/mongo_backend.py#L281-L292
tjcsl/ion
intranet/utils/helpers.py
debug_toolbar_callback
def debug_toolbar_callback(request): """Show the debug toolbar to those with the Django staff permission, excluding the Eighth Period office.""" if request.is_ajax(): return False if not hasattr(request, 'user'): return False if not request.user.is_authenticated: return Fal...
python
def debug_toolbar_callback(request): """Show the debug toolbar to those with the Django staff permission, excluding the Eighth Period office.""" if request.is_ajax(): return False if not hasattr(request, 'user'): return False if not request.user.is_authenticated: return Fal...
Show the debug toolbar to those with the Django staff permission, excluding the Eighth Period office.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/utils/helpers.py#L25-L41
tjcsl/ion
intranet/apps/announcements/models.py
AnnouncementManager.visible_to_user
def visible_to_user(self, user): """Get a list of visible announcements for a given user (usually request.user). These visible announcements will be those that either have no groups assigned to them (and are therefore public) or those in which the user is a member. Apparently t...
python
def visible_to_user(self, user): """Get a list of visible announcements for a given user (usually request.user). These visible announcements will be those that either have no groups assigned to them (and are therefore public) or those in which the user is a member. Apparently t...
Get a list of visible announcements for a given user (usually request.user). These visible announcements will be those that either have no groups assigned to them (and are therefore public) or those in which the user is a member. Apparently this .filter() call occasionally returns dupl...
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/announcements/models.py#L17-L30
tjcsl/ion
intranet/apps/announcements/models.py
AnnouncementManager.hidden_announcements
def hidden_announcements(self, user): """Get a list of announcements marked as hidden for a given user (usually request.user). These are all announcements visible to the user -- they have just decided to hide them. """ ids = user.announcements_hidden.all().values_list("announce...
python
def hidden_announcements(self, user): """Get a list of announcements marked as hidden for a given user (usually request.user). These are all announcements visible to the user -- they have just decided to hide them. """ ids = user.announcements_hidden.all().values_list("announce...
Get a list of announcements marked as hidden for a given user (usually request.user). These are all announcements visible to the user -- they have just decided to hide them.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/announcements/models.py#L32-L40
tjcsl/ion
intranet/apps/announcements/models.py
AnnouncementManager.this_year
def this_year(self): """ Get AnnouncementRequests from this school year only. """ start_date, end_date = get_date_range_this_year() return Announcement.objects.filter(added__gte=start_date, added__lte=end_date)
python
def this_year(self): """ Get AnnouncementRequests from this school year only. """ start_date, end_date = get_date_range_this_year() return Announcement.objects.filter(added__gte=start_date, added__lte=end_date)
Get AnnouncementRequests from this school year only.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/announcements/models.py#L42-L45
tjcsl/ion
intranet/apps/itemreg/views.py
register_calculator_view
def register_calculator_view(request): """Register a calculator.""" if request.method == "POST": form = CalculatorRegistrationForm(request.POST) logger.debug(form) if form.is_valid(): obj = form.save() obj.user = request.user obj.save() mes...
python
def register_calculator_view(request): """Register a calculator.""" if request.method == "POST": form = CalculatorRegistrationForm(request.POST) logger.debug(form) if form.is_valid(): obj = form.save() obj.user = request.user obj.save() mes...
Register a calculator.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/itemreg/views.py#L154-L169
tjcsl/ion
intranet/apps/itemreg/views.py
register_computer_view
def register_computer_view(request): """Register a computer.""" if request.method == "POST": form = ComputerRegistrationForm(request.POST) logger.debug(form) if form.is_valid(): obj = form.save() obj.user = request.user obj.save() messages....
python
def register_computer_view(request): """Register a computer.""" if request.method == "POST": form = ComputerRegistrationForm(request.POST) logger.debug(form) if form.is_valid(): obj = form.save() obj.user = request.user obj.save() messages....
Register a computer.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/itemreg/views.py#L174-L189
tjcsl/ion
intranet/apps/itemreg/views.py
register_phone_view
def register_phone_view(request): """Register a phone.""" if request.method == "POST": form = PhoneRegistrationForm(request.POST) logger.debug(form) if form.is_valid(): obj = form.save() obj.user = request.user obj.save() messages.success(r...
python
def register_phone_view(request): """Register a phone.""" if request.method == "POST": form = PhoneRegistrationForm(request.POST) logger.debug(form) if form.is_valid(): obj = form.save() obj.user = request.user obj.save() messages.success(r...
Register a phone.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/itemreg/views.py#L194-L209
tjcsl/ion
docs/conf.py
setup
def setup(app): """Setup autodoc.""" # Fix for documenting models.FileField from django.db.models.fields.files import FileDescriptor FileDescriptor.__get__ = lambda self, *args, **kwargs: self import django django.setup() app.connect('autodoc-skip-member', skip) app.add_stylesheet('_stat...
python
def setup(app): """Setup autodoc.""" # Fix for documenting models.FileField from django.db.models.fields.files import FileDescriptor FileDescriptor.__get__ = lambda self, *args, **kwargs: self import django django.setup() app.connect('autodoc-skip-member', skip) app.add_stylesheet('_stat...
Setup autodoc.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/docs/conf.py#L325-L333
tjcsl/ion
intranet/apps/users/views.py
profile_view
def profile_view(request, user_id=None): """Displays a view of a user's profile. Args: user_id The ID of the user whose profile is being viewed. If not specified, show the user's own profile. """ if request.user.is_eighthoffice and "full" not in request.GET and user_id ...
python
def profile_view(request, user_id=None): """Displays a view of a user's profile. Args: user_id The ID of the user whose profile is being viewed. If not specified, show the user's own profile. """ if request.user.is_eighthoffice and "full" not in request.GET and user_id ...
Displays a view of a user's profile. Args: user_id The ID of the user whose profile is being viewed. If not specified, show the user's own profile.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/users/views.py#L24-L96
tjcsl/ion
intranet/apps/users/views.py
picture_view
def picture_view(request, user_id, year=None): """Displays a view of a user's picture. Args: user_id The ID of the user whose picture is being fetched. year The user's picture from this year is fetched. If not specified, use the preferred picture. """ ...
python
def picture_view(request, user_id, year=None): """Displays a view of a user's picture. Args: user_id The ID of the user whose picture is being fetched. year The user's picture from this year is fetched. If not specified, use the preferred picture. """ ...
Displays a view of a user's picture. Args: user_id The ID of the user whose picture is being fetched. year The user's picture from this year is fetched. If not specified, use the preferred picture.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/users/views.py#L100-L158
tjcsl/ion
intranet/apps/eighth/views/attendance.py
generate_roster_pdf
def generate_roster_pdf(sched_act_ids, include_instructions): r"""Generates a PDF roster for one or more. :class:`EighthScheduledActivity`\s. Args sched_act_ids The list of IDs of the scheduled activities to show in the PDF. include_instructions Whether instructions...
python
def generate_roster_pdf(sched_act_ids, include_instructions): r"""Generates a PDF roster for one or more. :class:`EighthScheduledActivity`\s. Args sched_act_ids The list of IDs of the scheduled activities to show in the PDF. include_instructions Whether instructions...
r"""Generates a PDF roster for one or more. :class:`EighthScheduledActivity`\s. Args sched_act_ids The list of IDs of the scheduled activities to show in the PDF. include_instructions Whether instructions should be printed at the bottom of the roster(s). ...
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/views/attendance.py#L474-L593
tjcsl/ion
intranet/apps/eighth/views/activities.py
generate_statistics_pdf
def generate_statistics_pdf(activities=None, start_date=None, all_years=False, year=None): ''' Accepts EighthActivity objects and outputs a PDF file. ''' if activities is None: activities = EighthActivity.objects.all().order_by("name") if year is None: year = current_school_year() if no...
python
def generate_statistics_pdf(activities=None, start_date=None, all_years=False, year=None): ''' Accepts EighthActivity objects and outputs a PDF file. ''' if activities is None: activities = EighthActivity.objects.all().order_by("name") if year is None: year = current_school_year() if no...
Accepts EighthActivity objects and outputs a PDF file.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/views/activities.py#L58-L173
tjcsl/ion
intranet/apps/eighth/views/activities.py
stats_view
def stats_view(request, activity_id=None): """ If a the GET parameter `year` is set, it uses stats from given year with the following caveats: - If it's the current year and start_date is set, start_date is ignored - If it's the current year, stats will only show up to today - they w...
python
def stats_view(request, activity_id=None): """ If a the GET parameter `year` is set, it uses stats from given year with the following caveats: - If it's the current year and start_date is set, start_date is ignored - If it's the current year, stats will only show up to today - they w...
If a the GET parameter `year` is set, it uses stats from given year with the following caveats: - If it's the current year and start_date is set, start_date is ignored - If it's the current year, stats will only show up to today - they won't go into the future. `all...
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/views/activities.py#L293-L333
agoragames/kairos
kairos/sql_backend.py
SqlBackend.expire
def expire(self, name): ''' Expire all the data. ''' for interval,config in self._intervals.items(): if config['expire']: # Because we're storing the bucket time, expiry has the same # "skew" as whatever the buckets are. expire_from = config['i_calc'].to_bucket(time.time() ...
python
def expire(self, name): ''' Expire all the data. ''' for interval,config in self._intervals.items(): if config['expire']: # Because we're storing the bucket time, expiry has the same # "skew" as whatever the buckets are. expire_from = config['i_calc'].to_bucket(time.time() ...
Expire all the data.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/sql_backend.py#L161-L178
agoragames/kairos
kairos/sql_backend.py
SqlBackend._get
def _get(self, name, interval, config, timestamp, **kws): ''' Get the interval. ''' i_bucket = config['i_calc'].to_bucket(timestamp) fetch = kws.get('fetch') process_row = kws.get('process_row') or self._process_row rval = OrderedDict() if fetch: data = fetch( self._client.connect...
python
def _get(self, name, interval, config, timestamp, **kws): ''' Get the interval. ''' i_bucket = config['i_calc'].to_bucket(timestamp) fetch = kws.get('fetch') process_row = kws.get('process_row') or self._process_row rval = OrderedDict() if fetch: data = fetch( self._client.connect...
Get the interval.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/sql_backend.py#L189-L212
agoragames/kairos
kairos/sql_backend.py
SqlBackend.delete
def delete(self, name): ''' Delete time series by name across all intervals. Returns the number of records deleted. ''' conn = self._client.connect() conn.execute( self._table.delete().where(self._table.c.name==name) )
python
def delete(self, name): ''' Delete time series by name across all intervals. Returns the number of records deleted. ''' conn = self._client.connect() conn.execute( self._table.delete().where(self._table.c.name==name) )
Delete time series by name across all intervals. Returns the number of records deleted.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/sql_backend.py#L250-L256
agoragames/kairos
kairos/sql_backend.py
SqlSeries._insert_data
def _insert_data(self, name, value, timestamp, interval, config, **kwargs): '''Helper to insert data into sql.''' kwargs = { 'name' : name, 'interval' : interval, 'insert_time' : time.time(), 'i_time' : config['i_calc'].to_bucket(timestamp), 'value' : value ...
python
def _insert_data(self, name, value, timestamp, interval, config, **kwargs): '''Helper to insert data into sql.''' kwargs = { 'name' : name, 'interval' : interval, 'insert_time' : time.time(), 'i_time' : config['i_calc'].to_bucket(timestamp), 'value' : value ...
Helper to insert data into sql.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/sql_backend.py#L275-L288
agoragames/kairos
kairos/sql_backend.py
SqlGauge._insert_data
def _insert_data(self, name, value, timestamp, interval, config, **kwargs): '''Helper to insert data into sql.''' conn = self._client.connect() if not self._update_data(name, value, timestamp, interval, config, conn): try: kwargs = { 'name' : name, 'interval' : in...
python
def _insert_data(self, name, value, timestamp, interval, config, **kwargs): '''Helper to insert data into sql.''' conn = self._client.connect() if not self._update_data(name, value, timestamp, interval, config, conn): try: kwargs = { 'name' : name, 'interval' : in...
Helper to insert data into sql.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/sql_backend.py#L508-L526
agoragames/kairos
kairos/sql_backend.py
SqlGauge._update_data
def _update_data(self, name, value, timestamp, interval, config, conn): '''Support function for insert. Should be called within a transaction''' i_time = config['i_calc'].to_bucket(timestamp) if not config['coarse']: r_time = config['r_calc'].to_bucket(timestamp) else: r_time = None stmt...
python
def _update_data(self, name, value, timestamp, interval, config, conn): '''Support function for insert. Should be called within a transaction''' i_time = config['i_calc'].to_bucket(timestamp) if not config['coarse']: r_time = config['r_calc'].to_bucket(timestamp) else: r_time = None stmt...
Support function for insert. Should be called within a transaction
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/sql_backend.py#L528-L543
tjcsl/ion
intranet/utils/urls.py
add_get_parameters
def add_get_parameters(url, parameters, percent_encode=True): """Utility function to add GET parameters to an existing URL. Args: parameters A dictionary of the parameters that should be added. percent_encode Whether the query parameters should be percent encoded. R...
python
def add_get_parameters(url, parameters, percent_encode=True): """Utility function to add GET parameters to an existing URL. Args: parameters A dictionary of the parameters that should be added. percent_encode Whether the query parameters should be percent encoded. R...
Utility function to add GET parameters to an existing URL. Args: parameters A dictionary of the parameters that should be added. percent_encode Whether the query parameters should be percent encoded. Returns: The updated URL.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/utils/urls.py#L6-L28
tjcsl/ion
intranet/apps/context_processors.py
nav_categorizer
def nav_categorizer(request): """Determine which top-level nav category (left nav) a request falls under """ categories = [(r"^/$", "dashboard"), (r"^/announcements", "dashboard"), (r"^/eighth/admin", "eighth_admin"), (r"^/eighth", "eighth"), (r"^/events", "events"), (r"^/files", "fil...
python
def nav_categorizer(request): """Determine which top-level nav category (left nav) a request falls under """ categories = [(r"^/$", "dashboard"), (r"^/announcements", "dashboard"), (r"^/eighth/admin", "eighth_admin"), (r"^/eighth", "eighth"), (r"^/events", "events"), (r"^/files", "fil...
Determine which top-level nav category (left nav) a request falls under
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/context_processors.py#L26-L40
tjcsl/ion
intranet/apps/context_processors.py
mobile_app
def mobile_app(request): """Determine if the site is being displayed in a WebView from a native application.""" ctx = {} try: ua = request.META.get('HTTP_USER_AGENT', '') if "IonAndroid: gcmFrame" in ua: logger.debug("IonAndroid %s", request.user) ctx["is_android_c...
python
def mobile_app(request): """Determine if the site is being displayed in a WebView from a native application.""" ctx = {} try: ua = request.META.get('HTTP_USER_AGENT', '') if "IonAndroid: gcmFrame" in ua: logger.debug("IonAndroid %s", request.user) ctx["is_android_c...
Determine if the site is being displayed in a WebView from a native application.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/context_processors.py#L43-L83
tjcsl/ion
intranet/apps/context_processors.py
global_custom_theme
def global_custom_theme(request): """Add custom theme javascript and css.""" today = datetime.datetime.now().date() theme = {} if today.month == 3 and (14 <= today.day <= 16): theme = {"css": "themes/piday/piday.css"} return {"theme": theme}
python
def global_custom_theme(request): """Add custom theme javascript and css.""" today = datetime.datetime.now().date() theme = {} if today.month == 3 and (14 <= today.day <= 16): theme = {"css": "themes/piday/piday.css"} return {"theme": theme}
Add custom theme javascript and css.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/context_processors.py#L86-L94
tjcsl/ion
intranet/apps/context_processors.py
show_homecoming
def show_homecoming(request): """Show homecoming ribbon / scores """ return {'show_homecoming': settings.HOCO_START_DATE < datetime.date.today() and datetime.date.today() < settings.HOCO_END_DATE}
python
def show_homecoming(request): """Show homecoming ribbon / scores """ return {'show_homecoming': settings.HOCO_START_DATE < datetime.date.today() and datetime.date.today() < settings.HOCO_END_DATE}
Show homecoming ribbon / scores
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/context_processors.py#L97-L99
tjcsl/ion
intranet/utils/admin_helpers.py
export_csv_action
def export_csv_action(description="Export selected objects as CSV file", fields=None, exclude=None, header=True): """This function returns an export csv action. 'fields' and 'exclude' work like in django ModelForm 'header' is whether or not to output the column names as the first row. https://djangos...
python
def export_csv_action(description="Export selected objects as CSV file", fields=None, exclude=None, header=True): """This function returns an export csv action. 'fields' and 'exclude' work like in django ModelForm 'header' is whether or not to output the column names as the first row. https://djangos...
This function returns an export csv action. 'fields' and 'exclude' work like in django ModelForm 'header' is whether or not to output the column names as the first row. https://djangosnippets.org/snippets/2369/
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/utils/admin_helpers.py#L6-L43
tjcsl/ion
intranet/apps/eighth/management/commands/import_permissions.py
Command.handle
def handle(self, **options): """Exported "eighth_activity_permissions" table in CSV format.""" perm_map = {} with open('eighth_activity_permissions.csv', 'r') as absperms: perms = csv.reader(absperms) for row in perms: aid, uid = row try: ...
python
def handle(self, **options): """Exported "eighth_activity_permissions" table in CSV format.""" perm_map = {} with open('eighth_activity_permissions.csv', 'r') as absperms: perms = csv.reader(absperms) for row in perms: aid, uid = row try: ...
Exported "eighth_activity_permissions" table in CSV format.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/eighth/management/commands/import_permissions.py#L15-L47
tjcsl/ion
intranet/apps/polls/models.py
PollQuerySet.this_year
def this_year(self): """ Get AnnouncementRequests from this school year only. """ start_date, end_date = get_date_range_this_year() return self.filter(start_time__gte=start_date, start_time__lte=end_date)
python
def this_year(self): """ Get AnnouncementRequests from this school year only. """ start_date, end_date = get_date_range_this_year() return self.filter(start_time__gte=start_date, start_time__lte=end_date)
Get AnnouncementRequests from this school year only.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/polls/models.py#L17-L20
tjcsl/ion
intranet/apps/polls/models.py
PollManager.visible_to_user
def visible_to_user(self, user): """Get a list of visible polls for a given user (usually request.user). These visible polls will be those that either have no groups assigned to them (and are therefore public) or those in which the user is a member. """ return Poll.obj...
python
def visible_to_user(self, user): """Get a list of visible polls for a given user (usually request.user). These visible polls will be those that either have no groups assigned to them (and are therefore public) or those in which the user is a member. """ return Poll.obj...
Get a list of visible polls for a given user (usually request.user). These visible polls will be those that either have no groups assigned to them (and are therefore public) or those in which the user is a member.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/polls/models.py#L28-L37
tjcsl/ion
intranet/apps/printing/views.py
check_page_range
def check_page_range(page_range, max_pages): """Returns the number of pages in the range, or False if it is an invalid range.""" pages = 0 try: for r in page_range.split(","): # check all ranges separated by commas if "-" in r: rr = r.split("-") if len(rr...
python
def check_page_range(page_range, max_pages): """Returns the number of pages in the range, or False if it is an invalid range.""" pages = 0 try: for r in page_range.split(","): # check all ranges separated by commas if "-" in r: rr = r.split("-") if len(rr...
Returns the number of pages in the range, or False if it is an invalid range.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/printing/views.py#L128-L152
tjcsl/ion
intranet/apps/welcome/views.py
student_welcome_view
def student_welcome_view(request): """Welcome/first run page for students.""" if not request.user.is_student: return redirect("index") # context = {"first_login": request.session["first_login"] if "first_login" in request.session else False} # return render(request, "welcome/old_student.html", c...
python
def student_welcome_view(request): """Welcome/first run page for students.""" if not request.user.is_student: return redirect("index") # context = {"first_login": request.session["first_login"] if "first_login" in request.session else False} # return render(request, "welcome/old_student.html", c...
Welcome/first run page for students.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/welcome/views.py#L13-L19
tjcsl/ion
intranet/apps/announcements/notifications.py
request_announcement_email
def request_announcement_email(request, form, obj): """Send an announcement request email. form: The announcement request form obj: The announcement request object """ logger.debug(form.data) teacher_ids = form.data["teachers_requested"] if not isinstance(teacher_ids, list): teach...
python
def request_announcement_email(request, form, obj): """Send an announcement request email. form: The announcement request form obj: The announcement request object """ logger.debug(form.data) teacher_ids = form.data["teachers_requested"] if not isinstance(teacher_ids, list): teach...
Send an announcement request email. form: The announcement request form obj: The announcement request object
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/announcements/notifications.py#L22-L53
tjcsl/ion
intranet/apps/announcements/notifications.py
admin_request_announcement_email
def admin_request_announcement_email(request, form, obj): """Send an admin announcement request email. form: The announcement request form obj: The announcement request object """ subject = "News Post Approval Needed ({})".format(obj.title) emails = [settings.APPROVAL_EMAIL] base_url = re...
python
def admin_request_announcement_email(request, form, obj): """Send an admin announcement request email. form: The announcement request form obj: The announcement request object """ subject = "News Post Approval Needed ({})".format(obj.title) emails = [settings.APPROVAL_EMAIL] base_url = re...
Send an admin announcement request email. form: The announcement request form obj: The announcement request object
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/announcements/notifications.py#L56-L73
tjcsl/ion
intranet/apps/announcements/notifications.py
announcement_approved_email
def announcement_approved_email(request, obj, req): """Email the requested teachers and submitter whenever an administrator approves an announcement request. obj: the Announcement object req: the AnnouncementRequest object """ if not settings.PRODUCTION: logger.debug("Not in productio...
python
def announcement_approved_email(request, obj, req): """Email the requested teachers and submitter whenever an administrator approves an announcement request. obj: the Announcement object req: the AnnouncementRequest object """ if not settings.PRODUCTION: logger.debug("Not in productio...
Email the requested teachers and submitter whenever an administrator approves an announcement request. obj: the Announcement object req: the AnnouncementRequest object
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/announcements/notifications.py#L76-L113
tjcsl/ion
intranet/apps/announcements/notifications.py
announcement_posted_email
def announcement_posted_email(request, obj, send_all=False): """Send a notification posted email. obj: The announcement object """ if settings.EMAIL_ANNOUNCEMENTS: subject = "Announcement: {}".format(obj.title) if send_all: users = User.objects.all() else: ...
python
def announcement_posted_email(request, obj, send_all=False): """Send a notification posted email. obj: The announcement object """ if settings.EMAIL_ANNOUNCEMENTS: subject = "Announcement: {}".format(obj.title) if send_all: users = User.objects.all() else: ...
Send a notification posted email. obj: The announcement object
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/announcements/notifications.py#L116-L163
tjcsl/ion
intranet/apps/notifications/emails.py
email_send
def email_send(text_template, html_template, data, subject, emails, headers=None): """Send an HTML/Plaintext email with the following fields. text_template: URL to a Django template for the text email's contents html_template: URL to a Django tempalte for the HTML email's contents data: The context to ...
python
def email_send(text_template, html_template, data, subject, emails, headers=None): """Send an HTML/Plaintext email with the following fields. text_template: URL to a Django template for the text email's contents html_template: URL to a Django tempalte for the HTML email's contents data: The context to ...
Send an HTML/Plaintext email with the following fields. text_template: URL to a Django template for the text email's contents html_template: URL to a Django tempalte for the HTML email's contents data: The context to pass to the templates subject: The subject of the email emails: The addresses to s...
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/notifications/emails.py#L12-L35
tjcsl/ion
intranet/apps/templatetags/form_field.py
field_
def field_(self, name): """ From https://github.com/halfnibble/django-underscore-filters Get a form field starting with _. Taken near directly from Django > forms. Returns a BoundField with the given name. """ try: field = self.fields[name] except KeyError: raise KeyErro...
python
def field_(self, name): """ From https://github.com/halfnibble/django-underscore-filters Get a form field starting with _. Taken near directly from Django > forms. Returns a BoundField with the given name. """ try: field = self.fields[name] except KeyError: raise KeyErro...
From https://github.com/halfnibble/django-underscore-filters Get a form field starting with _. Taken near directly from Django > forms. Returns a BoundField with the given name.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/templatetags/form_field.py#L8-L20
agoragames/kairos
kairos/cassandra_backend.py
scoped_connection
def scoped_connection(func): ''' Decorator that gives out connections. ''' def _with(series, *args, **kwargs): connection = None try: connection = series._connection() return func(series, connection, *args, **kwargs) finally: series._return( connection ) return _with
python
def scoped_connection(func): ''' Decorator that gives out connections. ''' def _with(series, *args, **kwargs): connection = None try: connection = series._connection() return func(series, connection, *args, **kwargs) finally: series._return( connection ) return _with
Decorator that gives out connections.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/cassandra_backend.py#L66-L77
agoragames/kairos
kairos/cassandra_backend.py
CassandraBackend._connection
def _connection(self): ''' Return a connection from the pool ''' try: return self._pool.get(False) except Empty: args = [ self._host, self._port, self._keyspace ] kwargs = { 'user' : None, 'password' : None, 'cql_version' ...
python
def _connection(self): ''' Return a connection from the pool ''' try: return self._pool.get(False) except Empty: args = [ self._host, self._port, self._keyspace ] kwargs = { 'user' : None, 'password' : None, 'cql_version' ...
Return a connection from the pool
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/cassandra_backend.py#L145-L166
agoragames/kairos
kairos/cassandra_backend.py
CassandraBackend._insert
def _insert(self, name, value, timestamp, intervals, **kwargs): ''' Insert the new value. ''' if self._value_type in QUOTE_TYPES and not QUOTE_MATCH.match(value): value = "'%s'"%(value) for interval,config in self._intervals.items(): timestamps = self._normalize_timestamps(timestamp, in...
python
def _insert(self, name, value, timestamp, intervals, **kwargs): ''' Insert the new value. ''' if self._value_type in QUOTE_TYPES and not QUOTE_MATCH.match(value): value = "'%s'"%(value) for interval,config in self._intervals.items(): timestamps = self._normalize_timestamps(timestamp, in...
Insert the new value.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/cassandra_backend.py#L175-L185
agoragames/kairos
kairos/cassandra_backend.py
CassandraBackend._insert_data
def _insert_data(self, connection, name, value, timestamp, interval, config): '''Helper to insert data into cql.''' cursor = connection.cursor() try: stmt = self._insert_stmt(name, value, timestamp, interval, config) if stmt: cursor.execute(stmt) finally: cursor.close()
python
def _insert_data(self, connection, name, value, timestamp, interval, config): '''Helper to insert data into cql.''' cursor = connection.cursor() try: stmt = self._insert_stmt(name, value, timestamp, interval, config) if stmt: cursor.execute(stmt) finally: cursor.close()
Helper to insert data into cql.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/cassandra_backend.py#L188-L196
agoragames/kairos
kairos/cassandra_backend.py
CassandraBackend._series
def _series(self, connection, name, interval, config, buckets, **kws): ''' Fetch a series of buckets. ''' fetch = kws.get('fetch') process_row = kws.get('process_row') or self._process_row rval = OrderedDict() if fetch: data = fetch( connection, self._table, name, interval, buckets )...
python
def _series(self, connection, name, interval, config, buckets, **kws): ''' Fetch a series of buckets. ''' fetch = kws.get('fetch') process_row = kws.get('process_row') or self._process_row rval = OrderedDict() if fetch: data = fetch( connection, self._table, name, interval, buckets )...
Fetch a series of buckets.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/cassandra_backend.py#L225-L259
agoragames/kairos
kairos/cassandra_backend.py
CassandraSet._insert_stmt
def _insert_stmt(self, name, value, timestamp, interval, config): '''Helper to generate the insert statement.''' # Calculate the TTL and abort if inserting into the past expire, ttl = config['expire'], config['ttl'](timestamp) if expire and not ttl: return None i_time = config['i_calc'].to_bu...
python
def _insert_stmt(self, name, value, timestamp, interval, config): '''Helper to generate the insert statement.''' # Calculate the TTL and abort if inserting into the past expire, ttl = config['expire'], config['ttl'](timestamp) if expire and not ttl: return None i_time = config['i_calc'].to_bu...
Helper to generate the insert statement.
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/cassandra_backend.py#L646-L665
tjcsl/ion
intranet/apps/events/models.py
EventManager.visible_to_user
def visible_to_user(self, user): """Get a list of visible events for a given user (usually request.user). These visible events will be those that either have no groups assigned to them (and are therefore public) or those in which the user is a member. """ return (Event...
python
def visible_to_user(self, user): """Get a list of visible events for a given user (usually request.user). These visible events will be those that either have no groups assigned to them (and are therefore public) or those in which the user is a member. """ return (Event...
Get a list of visible events for a given user (usually request.user). These visible events will be those that either have no groups assigned to them (and are therefore public) or those in which the user is a member.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/events/models.py#L36-L45
tjcsl/ion
intranet/apps/events/models.py
EventManager.hidden_events
def hidden_events(self, user): """Get a list of events marked as hidden for a given user (usually request.user). These are all events visible to the user -- they have just decided to hide them. """ ids = user.events_hidden.all().values_list("event__id") return Event.obj...
python
def hidden_events(self, user): """Get a list of events marked as hidden for a given user (usually request.user). These are all events visible to the user -- they have just decided to hide them. """ ids = user.events_hidden.all().values_list("event__id") return Event.obj...
Get a list of events marked as hidden for a given user (usually request.user). These are all events visible to the user -- they have just decided to hide them.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/events/models.py#L47-L55
tjcsl/ion
intranet/apps/events/models.py
Event.show_fuzzy_date
def show_fuzzy_date(self): """Return whether the event is in the next or previous 2 weeks. Determines whether to display the fuzzy date. """ date = self.time.replace(tzinfo=None) if date <= datetime.now(): diff = datetime.now() - date if diff.days >= 14:...
python
def show_fuzzy_date(self): """Return whether the event is in the next or previous 2 weeks. Determines whether to display the fuzzy date. """ date = self.time.replace(tzinfo=None) if date <= datetime.now(): diff = datetime.now() - date if diff.days >= 14:...
Return whether the event is in the next or previous 2 weeks. Determines whether to display the fuzzy date.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/events/models.py#L164-L180
tjcsl/ion
intranet/apps/templatetags/dates.py
fuzzy_date
def fuzzy_date(date): """Formats a `datetime.datetime` object relative to the current time.""" date = date.replace(tzinfo=None) if date <= datetime.now(): diff = datetime.now() - date seconds = diff.total_seconds() minutes = seconds // 60 hours = minutes // 60 if ...
python
def fuzzy_date(date): """Formats a `datetime.datetime` object relative to the current time.""" date = date.replace(tzinfo=None) if date <= datetime.now(): diff = datetime.now() - date seconds = diff.total_seconds() minutes = seconds // 60 hours = minutes // 60 if ...
Formats a `datetime.datetime` object relative to the current time.
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/templatetags/dates.py#L28-L76
tjcsl/ion
intranet/apps/signage/templatetags/signage.py
render_page
def render_page(page, page_args): """ Renders the template at page.template """ print(page_args) template_name = page.template if page.template else page.name template = "signage/pages/{}.html".format(template_name) if page.function: context_method = getattr(pages, page.function) els...
python
def render_page(page, page_args): """ Renders the template at page.template """ print(page_args) template_name = page.template if page.template else page.name template = "signage/pages/{}.html".format(template_name) if page.function: context_method = getattr(pages, page.function) els...
Renders the template at page.template
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/signage/templatetags/signage.py#L10-L22
tjcsl/ion
intranet/apps/announcements/views.py
announcement_posted_hook
def announcement_posted_hook(request, obj): """Runs whenever a new announcement is created, or a request is approved and posted. obj: The Announcement object """ logger.debug("Announcement posted") if obj.notify_post: logger.debug("Announcement notify on") announcement_posted_twit...
python
def announcement_posted_hook(request, obj): """Runs whenever a new announcement is created, or a request is approved and posted. obj: The Announcement object """ logger.debug("Announcement posted") if obj.notify_post: logger.debug("Announcement notify on") announcement_posted_twit...
Runs whenever a new announcement is created, or a request is approved and posted. obj: The Announcement object
https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/announcements/views.py#L40-L66