Пример #1
0
    def test_gbobjects_published(self):
        Objecttype = self.objecttypes[0]
        self.assertEqual(Objecttype.gbobjects_published().count(), 0)
        self.gbobject.status = PUBLISHED
        self.gbobject.save()
        self.assertEqual(Objecttype.gbobjects_published().count(), 1)

        params = {'title': 'My second gbobject',
                  'content': 'My second content',
                  'tags': 'objectapp, test',
                  'status': PUBLISHED,
                  'slug': 'my-second-gbobject'}

        new_gbobject = Gbobject.objects.create(**params)
        new_gbobject.sites.add(self.site)
        new_gbobject.objecttypes.add(self.objecttypes[0])

        self.assertEqual(self.objecttypes[0].gbobjects_published().count(), 2)
        self.assertEqual(self.objecttypes[1].gbobjects_published().count(), 1)
Пример #2
0
def Objecttype_detail(request, path, page=None, **kwargs):
    """Display the gbobjects of a Objecttype"""
    extra_context = kwargs.pop("extra_context", {})

    Objecttype = get_Objecttype_or_404(path)
    if not kwargs.get("template_name"):
        kwargs["template_name"] = template_name_for_gbobject_queryset_filtered("Objecttype", Objecttype.slug)

    extra_context.update({"Objecttype": Objecttype})
    kwargs["extra_context"] = extra_context

    return object_list(request, queryset=Objecttype.gbobjects_published(), paginate_by=PAGINATION, page=page, **kwargs)
Пример #3
0
def Objecttype_detail(request, path, page=None, **kwargs):
    """Display the gbobjects of a Objecttype"""
    extra_context = kwargs.pop('extra_context', {})

    Objecttype = get_Objecttype_or_404(path)
    if not kwargs.get('template_name'):
        kwargs['template_name'] = template_name_for_gbobject_queryset_filtered(
            'Objecttype', Objecttype.slug)

    extra_context.update({'Objecttype': Objecttype})
    kwargs['extra_context'] = extra_context

    return object_list(request, queryset=Objecttype.gbobjects_published(),
                       paginate_by=PAGINATION, page=page,
                       **kwargs)