def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) tab_nav = [ { 'url': self.object.get_absolute_url, 'title': _('Details') }, { 'url': self.object.members_view_uri, 'title': _('Members ').__str__() + Badge(content=str(self.object.primary_users.count()), color=BadgeColorEnum.SECONDARY) }, { 'url': self.object.publishers_uri, 'title': _('Publishers ').__str__() + Badge(content=str(self.object.publishers.count()), color=BadgeColorEnum.SECONDARY) }, ] context.update({ "object": self.object, 'actions': self.object.get_actions(), 'tab_nav': tab_nav, 'publisher_requests_count': PublishRequest.objects.filter(organization=self.object).count() }) return context
def show_pending_requests(self): icon = Tag(tag='i', attrs={ "class": [IconEnum.PUBLISHERS.value] }).render() count = Badge( content=f" {PublishRequest.objects.filter(group=self).count()}", color=BadgeColorEnum.SECONDARY).render() st_text = Tag(tag='div', attrs={ "class": ['d-lg-none'] }, content=icon + count).render() gt_text = Tag(tag='div', attrs={ "class": ['d-none', 'd-lg-block'] }, content=icon + _(' pending requests').__str__() + count).render() return LinkButton( url= f"{reverse('structure:publish_request_overview')}?group={self.pk}", content=f"{st_text}{gt_text}", color=ButtonColorEnum.INFO, tooltip=_(f"see pending requests for {self}"), needs_perm=PermissionEnum.CAN_REQUEST_TO_BECOME_PUBLISHER.value)
def render_status_code(self, value): if 200 <= value < 300: color = BadgeColorEnum.SUCCESS elif 400 <= value < 500: color = BadgeColorEnum.WARNING elif 500 <= value < 600: color = BadgeColorEnum.DANGER else: color = BadgeColorEnum.SECONDARY return Badge(content=value, color=color).render(safe=True)
def render_mime_types(self, record): mime_types = {} formats = record.get_formats() for mime in formats: op = mime_types.get(mime.operation) if op is None: op = [] op.append(mime.mime_type) mi = {mime.operation: op} mime_types.update(mi) mime_type_accordions = '' for key, values in mime_types.items(): badges = '' for value in values: badges += Badge(content=value) mime_type_accordions += Accordion(btn_value=key, content=badges) return format_html(mime_type_accordions)
def render_reference_system__all(self, value): badges = '' for kw in value: badges += Badge(content=f'{kw.prefix}:{kw.code}', badge_pill=True) return format_html(badges) if value else _( 'No additional reference systems provided')
def render_featuretype__default_srs(self, value): badge = Badge(content=f'{value.prefix}:{value.code}', badge_pill=True).render(safe=True) return badge if value else _('No default reference system provided')
def render_keywords__all(self, value): badges = '' for kw in value: badges += Badge(content=kw, badge_pill=True) return format_html(badges) if value else _('No keywords provided')