Пример #1
0
    def get_context_data(self, **kwargs):
        context = super(BaseInboxView, self).get_context_data(**kwargs)
        org = self.request.org
        user = self.request.user
        partner = user.get_partner(org)

        labels = list(Label.get_all(org, user).order_by("name"))
        Label.bulk_cache_initialize(labels)

        fields = Field.get_all(org, visible=True).order_by("label")

        # angular app requires context data in JSON format
        context["context_data_json"] = json_encode({
            "user": {
                "id": user.pk,
                "partner": partner.as_json() if partner else None
            },
            "labels": [l.as_json() for l in labels],
            "fields": [f.as_json() for f in fields],
        })

        context["banner_text"] = org.get_banner_text()
        context["folder"] = self.folder.name
        context["folder_icon"] = self.folder_icon
        context["open_case_count"] = Case.get_open(org, user).count()
        context["closed_case_count"] = Case.get_closed(org, user).count()
        context["allow_case_without_message"] = getattr(
            settings, "SITE_ALLOW_CASE_WITHOUT_MESSAGE", False)
        context[
            "user_must_reply_with_faq"] = org and not user.is_anonymous and user.must_use_faq(
            )
        context["site_contact_display"] = getattr(settings,
                                                  "SITE_CONTACT_DISPLAY",
                                                  "name")
        return context
Пример #2
0
    def get_context_data(self, **kwargs):
        context = super(BaseInboxView, self).get_context_data(**kwargs)
        org = self.request.org
        user = self.request.user
        partner = user.get_partner(org)

        labels = list(Label.get_all(org, user).order_by('name'))
        Label.bulk_cache_initialize(labels)

        groups = Group.get_all(org, visible=True).order_by('name')
        fields = Field.get_all(org, visible=True).order_by('label')

        # angular app requires context data in JSON format
        context['context_data_json'] = json_encode({
            'user': {
                'id': user.pk,
                'partner': partner.as_json() if partner else None
            },
            'labels': [l.as_json() for l in labels],
            'groups': [g.as_json() for g in groups],
            'fields': [f.as_json() for f in fields],
        })

        context['banner_text'] = org.get_banner_text()
        context['folder'] = self.folder.name
        context['folder_icon'] = self.folder_icon
        context['open_case_count'] = Case.get_open(org, user).count()
        context['closed_case_count'] = Case.get_closed(org, user).count()
        context['allow_case_without_message'] = getattr(
            settings, 'SITE_ALLOW_CASE_WITHOUT_MESSAGE', False)
        context['user_must_reply_with_faq'] = org and not user.is_anonymous(
        ) and user.must_use_faq()
        context['site_contact_display'] = getattr(settings,
                                                  'SITE_CONTACT_DISPLAY',
                                                  "name")
        return context