Example #1
0
    def get_context_data(self, **kwargs):
        default_context = super(ResourceScheduleTemplateView, self).get_context_data(**kwargs)
        resource_list_query = self.bookable_resource_class.objects.all()
        resource_list = []
        for resource in resource_list_query:
            resource_list.append({"id": str(resource.pk), "title": resource.get_title()})
        default_context["resource_list"] = json.dumps(resource_list)
        default_context["resource_type"] = self.resource_title
        default_context["get_schedule"] = reverse(self.get_schedule_url_name)

        # default_context["new_resource_form"] = self.resource_create_view_class().get_form_class()
        form_factory = ModelFormFactory(self.bookable_resource_class)
        form_factory.set_exclude("approver")
        default_context["new_resource_form"] = form_factory.get_form_class()()

        default_context["booking_req_form"] = self.request_create_view().get_form_class()
        default_context["resource_detail"] = self.resource_detail
        # default_context["color_for_need_approval_from_others"] = self.WAITING_FOR_APPROVAL_FROM_OTHERS_COLOR
        # default_context["color_for_approved"] = self.APPROVED_COLOR
        # default_context["color_for_ongoing"] = self.ONGOING_COLOR
        # default_context["color_for_need_your_approval"] = self.WAITING_FOR_YOUR_APPROVAL_COLOR
        default_context["event_colors"] = json.dumps(self.get_colors())
        data = retrieve_param(self.request)
        if "start" in data:
            default_context["year"] = int(data["start"])
        else:
            default_context["year"] = 2015

        default_context["is_admin"] = "false"
        default_context["page_title"] = self.page_title
        if self.request.user.has_perm(self.resource_permission_id):
            default_context["is_admin"] = "true"
        return default_context
 def get_template_view_factory(self):
     f = TemplateViewFactory()
     f.set_exclude(["approver"])
     f.add_parent_class([AjaxableFormContextUpdateMixin, ResourceApproverUpdater])
     f.set_model_class(self.__base_resource_model_class)
     model_factory = ModelFormFactory(self.__base_resource_model_class)
     model_factory.set_exclude(["approver"])
     form_class = model_factory.get_form_class()
     f.set_form_class(form_class)
     return f