Ejemplo n.º 1
0
 def init_form(self, user):
     if user.is_superuser:
         cats = get_cached_list(Category, tree_parent__isnull=True)
     else:
         category_ids = DenormalizedCategoryUserRole.objects.root_categories_by_user(user)
         cats = get_cached_list(Category, pk__in=category_ids)
     choices = ()
     for c in cats:
         choices += (c.pk, c.__unicode__(),),
     self.sites_count = len(choices)
     self.fields['sites'] = forms.MultipleChoiceField(choices, widget=CheckboxSelectMultiple, required=False)
Ejemplo n.º 2
0
 def init_form(self, user):
     if user.is_superuser:
         cats = get_cached_list(Category, tree_parent__isnull=True)
     else:
         category_ids = DenormalizedCategoryUserRole.objects.root_categories_by_user(user)
         cats = get_cached_list(Category, pk__in=category_ids)
     choices = ()
     for c in cats:
         choices += (c.pk, c.__unicode__(),),
     self.sites_count = len(choices)
     self.fields['sites'] = forms.MultipleChoiceField(choices, widget=CheckboxSelectMultiple, required=False)
Ejemplo n.º 3
0
    def applicable_content_types(self):

        acts = []
        cts = get_cached_list(ContentType)
        for ct in cts:
            cls = ct.model_class()
            if cls and (issubclass(cls, Publishable) or '%s.%s' % (ct.app_label, ct.model) in newman_settings.NON_PUBLISHABLE_CTS):
                acts.append(ct)

        return acts
Ejemplo n.º 4
0
    def get_serieparts_for_current_part(self, current_part):
        """  Return all parts for given part """
        kwargs = {'serie': current_part.serie}
        # Shall I hide newer parts?
        if current_part.serie.hide_newer_parts:
            kwargs['publishable__publish_from__lte'] = current_part.publishable.publish_from
        else:
            kwargs['publishable__publish_from__lte'] = datetime.now()

        return get_cached_list(SeriePart, **kwargs)
Ejemplo n.º 5
0
    def applicable_content_types(self):

        acts = []
        cts = get_cached_list(ContentType)
        for ct in cts:
            cls = ct.model_class()
            if cls and (issubclass(cls, Publishable) or '%s.%s' %
                        (ct.app_label, ct.model)
                        in newman_settings.NON_PUBLISHABLE_CTS):
                acts.append(ct)

        return acts
Ejemplo n.º 6
0
 def parts(self):
     return get_cached_list(SeriePart, serie=self, publishable__publish_from__lte=datetime.now())