Example #1
0
def fullcal(request):
  c = ConferenceResource()
  ce = ConfEventResource()

  ce_json = cache.get('ce_json')
  if not ce_json:
    today = date.today()
    first = date(today.year, today.month, 1)
    first_prev = (first - relativedelta(months=4))
    first_next = (first + relativedelta(months=8))
    start = date_to_timezone(first_prev + relativedelta(days=22)) # 23rd is earliest day possibly displayed = leap year with 3/1 on Saturday
    end = date_to_timezone(first_next + relativedelta(days=12)) # 13th is latest day possibly displayed = last day of current month on Sunday

    ce_json = get_initial_json(ce, start__gte=start, start__lt=end)
    cache.set('ce_json', ce_json, 86400) # 60s x 60min x 24h = 86400s

  c_json = cache.get('c_json')
  if not c_json:
    c_json = get_initial_json(c)
    cache.set('c_json', c_json, 2592000) # i think this is the maximum possible

  divs = SortedDict(DIV_CHOICES)

  return direct_to_template(request, 'radcal/fullcal.html', extra_context = {
             'ce_json': ce_json,
             'c_json': c_json,
             'divs': divs,
             }
  )
Example #2
0
def call(request):
  ef = EventFilterResource()
  se = ShiftEventResource()
  ce = ConfEventResource()
  s = ShiftResource()
  c = ConferenceResource()
  u = radprofile.resources.UserResource()

  sub = taxonomy.resources.SubspecialtyResource()

  for key, resource in [('se_json', se), ('ce_json', ce)]:
    if not cache.get(key):
      today = date.today()
      first = date(today.year, today.month, 1)
      first_prev = (first - relativedelta(months=1))
      first_next = (first + relativedelta(months=2))
      start = date_to_timezone(first_prev + relativedelta(days=22)) # 23rd is earliest day possibly displayed = leap year with 3/1 on Saturday
      end = date_to_timezone(first_next + relativedelta(days=12)) # 13th is latest day possibly displayed = last day of current month on Sunday

      json = get_initial_json(resource, start__gte=start, start__lt=end)
      cache.set(key, json, 43200) # 60s x 60min x 24h = 86400s
  #
  for key, resource in [('s_json', s), ('c_json', c), ('sub_json', sub)]: #('u_json', u)
    if not cache.get(key):
      json = get_initial_json(resource)
      cache.set(key, json, 2592000) # i think this is the maximum possible

  if not cache.get('u_json'):
    u_json = get_initial_json(u)
    cache.set('u_json', u_json, 2592000) # i think this is the maximum possible
  #
  for key, resource in [('ef_json', ef)]:
    json = get_initial_json(resource)
    cache.set(key, json, 2592000) # i think this is the maximum possible

  return direct_to_template(request, 'radcal/call.html', extra_context = {
               'se_json': cache.get('se_json'),
               'ce_json': cache.get('ce_json'),
               's_json': cache.get('s_json'),
               'c_json': cache.get('c_json'),
               'u_json': cache.get('u_json'),
               'sub_json': cache.get('sub_json'),
               'ef_json': cache.get('ef_json'),
               'divs': SortedDict(DIV_CHOICES)
               }
  )