[docs]@eighth_admin_requireddefeighth_admin_dashboard_view(request,**kwargs):start_date=get_start_date(request)all_activities=EighthActivity.objects.order_by("name").only("id","name","special","restricted","both_blocks","administrative","sticky","deleted")# show deleted activitiesblocks_after_start_date=EighthBlock.objects.filter(date__gte=start_date).order_by("date")next_block_after_start_date=blocks_after_start_date.first()ifnext_block_after_start_dateisNone:blocks_next=EighthBlock.objects.none()blocks_next_date=Noneelse:blocks_next_date=next_block_after_start_date.dateblocks_next=EighthBlock.objects.filter(date=blocks_next_date)groups=Group.objects.prefetch_related("groupproperties").annotate(user_count=Count("user")).order_by("name")rooms=EighthRoom.objects.all()sponsors=(EighthSponsor.objects.select_related("user").only("id","last_name","first_name","show_full_name","user__id").order_by("last_name","first_name"))signup_users_count=get_user_model().objects.get_students().count()context={"start_date":start_date,"all_activities":all_activities,"blocks_after_start_date":blocks_after_start_date,"groups":groups,"rooms":rooms,"sponsors":sponsors,"blocks_next":blocks_next,"blocks_next_date":blocks_next_date,"signup_users_count":signup_users_count,"admin_page_title":"Eighth Period Admin",# Used in place of IDs in data-href-pattern tags of .dynamic-links# to reverse single-ID urls in Javascript. It's rather hacky, but# not unlike boundaries of multipart/form-data requests, so it's# not completely bad. If there's a better way to do this,# please implement it."url_id_placeholder":"734784857438457843756435654645642343465",}forms={"add_group_form":group_forms.QuickGroupForm,"add_room_form":room_forms.RoomForm}forform_name,form_classinforms.items():form_css_id=form_name.replace("_","-")ifform_nameinkwargs:context[form_name]=kwargs.get(form_name)context["scroll_to_id"]=form_css_idelifform_nameinrequest.session:context["scroll_to_id"]=form_css_idelse:context[form_name]=form_class()#######ifsettings.ENABLE_HYBRID_EIGHTH:context.update({"hybrid":True})#######returnrender(request,"eighth/admin/dashboard.html",context)
[docs]@eighth_admin_requireddefcache_view(request):ifrequest.method=="POST":if"invalidate_all"inrequest.POST:invalidate_all()messages.success(request,"Invalidated all of the cache")try:opts=settings.CACHEOPSdefault=settings.CACHEOPS_DEFAULTSexceptAttributeError:opts=default=Nonecache={}ifopts:forctypeinopts:c=ctype.split(".",1)[0]if"timeout"inopts[ctype]:to=opts[ctype]["timeout"]else:to=default["timeout"]cache[c]=int(to/(60*60))context={"admin_page_title":"Cache Configuration","cache_length":cache}returnrender(request,"eighth/admin/cache.html",context)