コード例 #1
0
def daily_table(context, day, width, width_slot, height, start=8, end=20, increment=30):
    """
      Display a nice table with occurrences and action buttons.
      Arguments:
      width - width of the table (px)
      width_slot - width of the slot column (px)
      height - height of the table
      start - hour at which the day starts
      end - hour at which the day ends
      increment - size of a time slot (in minutes)
    """
    user = context['request'].user
    addable = CHECK_EVENT_PERM_FUNC(None, user)
    CHECK_EVENT_PERM_FUNC(None, user)
    if 'calendar' in context:
        addable &= CHECK_CALENDAR_PERM_FUNC(context['calendar'], user)
    context['addable'] = addable

    width_occ = width - width_slot
    day_part = day.get_time_slot(day.start + datetime.timedelta(hours=start), day.start + datetime.timedelta(hours=end))
    occurrences = day_part.get_occurrences()
    occurrences = _cook_occurrences(day_part, occurrences, width_occ, height)
    # get slots to display on the left
    slots = _cook_slots(day_part, increment, width, height)
    context['occurrences'] = occurrences
    context['slots'] = slots
    context['width'] = width
    context['width_slot'] = width_slot
    context['width_occ'] = width_occ
    context['height'] = height
    return context
コード例 #2
0
def laundryapp_daily_table(context, day, start=6, end=23, increment=60):
    user = context['request'].user
    addable = CHECK_EVENT_PERM_FUNC(None, user)
    if 'calendar' in context:
        addable &= CHECK_CALENDAR_PERM_FUNC(context['calendar'], user)
    context['addable'] = addable

    day_part = day.get_time_slot(day.start + datetime.timedelta(hours=start), day.start + datetime.timedelta(hours=end))
    # get slots to display on the left
    slots = _cook_slots(day_part, increment)
    context['slots'] = slots
    return context
コード例 #3
0
 def decorator(request, *args, **kwargs):
     from schedule.models import Event, Calendar, Occurrence
     user = request.user
     if not user:
         return HttpResponseRedirect(settings.LOGIN_URL)
     occurrence, event, calendar = get_objects(request, *args, **kwargs)
     if calendar:
         allowed = (CHECK_EVENT_PERM_FUNC(event, user) and \
             CHECK_CALENDAR_PERM_FUNC(calendar, user))
         if not allowed:
             return HttpResponseRedirect(settings.LOGIN_URL)
         # all checks passed
         return function(request, *args, **kwargs)
     return HttpResponseNotFound('<h1>Page not found</h1>')
コード例 #4
0
def options(context, occurrence):
    context.update({
        'occurrence': occurrence,
        'MEDIA_URL': getattr(settings, "MEDIA_URL"),
    })
    context['view_occurrence'] = occurrence.get_absolute_url()
    user = context['request'].user
    if CHECK_EVENT_PERM_FUNC(occurrence.event, user) and CHECK_CALENDAR_PERM_FUNC(occurrence.event.calendar, user):
        context['edit_occurrence'] = occurrence.get_edit_url()
        context['cancel_occurrence'] = occurrence.get_cancel_url()
        context['delete_event'] = reverse('delete_event', args=(occurrence.event.id,))
        context['edit_event'] = reverse('edit_event', args=(occurrence.event.calendar.slug, occurrence.event.id,))
    else:
        context['edit_event'] = context['delete_event'] = ''
    return context
コード例 #5
0
ファイル: utils.py プロジェクト: JohnHammond/cdx_2016
 def decorator(request, *args, **kwargs):
     if CALENDAR_VIEW_PERM:
         from schedule.models import Event, Calendar
         user = request.user
         # check event permission
         event = get_object_or_None(Event, pk=kwargs.get('event_id', None))
         # check calendar permissions
         calendar = None
         if event:
             calendar = event.calendar
         elif 'calendar_slug' in kwargs:
             calendar = Calendar.objects.get(slug=kwargs['calendar_slug'])
         allowed = CHECK_CALENDAR_PERM_FUNC(calendar, user)
         if not allowed:
             return HttpResponseRedirect(settings.LOGIN_URL)
         # all checks passed
     return function(request, *args, **kwargs)
コード例 #6
0
def daily_table(context, day, start=0, end=24, increment=30):
    """
      Display a nice table with occurrences and action buttons.
      Arguments:
      start - hour at which the day starts
      end - hour at which the day ends
      increment - size of a time slot (in minutes)
    """
    user = context['request'].user
    addable = CHECK_EVENT_PERM_FUNC(None, user)
    if 'calendar' in context:
        addable &= CHECK_CALENDAR_PERM_FUNC(context['calendar'], user)
    context['addable'] = addable

    day_part = day.get_time_slot(day.start + datetime.timedelta(hours=start), day.start + datetime.timedelta(hours=end))
    # get slots to display on the left
    slots = _cook_slots(day_part, increment)
    context['slots'] = slots
    return context