예제 #1
0
    def queryset(self, start_at=None):
        if self.region:
            qs = Page.versions.filter(region=self.region)
        else:
            qs = Page.versions.all()

        if start_at:
            qs = qs.filter(version_info__date__gte=start_at)

        return qs.defer('content')

    def page(self, obj):
        return obj


activity.register(PageChanges)


class PageFileChanges(ActivityForModel):
    classname = 'file'

    def queryset(self, start_at=None):
        if self.region:
            qs = PageFile.versions.filter(region=self.region)
        else:
            qs = PageFile.versions.all()

        if start_at:
            qs = qs.filter(version_info__date__gte=start_at)
        return qs
예제 #2
0
        if self.region:
            qs = PageTagSet.versions.filter(region=self.region)
        else:
            qs = PageTagSet.versions.all()

        if start_at:
            qs = qs.filter(version_info__date__gte=start_at)
        return qs

    def page(self, obj):
        return obj.page

    def title(self, obj):
        return 'Tags on page "%s"' % self.page(obj).name

    def diff_url(self, obj):
        return reverse('pages:tags-compare-dates', kwargs={
            'slug': self.page(obj).pretty_slug,
            'region': self.page(obj).region.slug,
            'date1': obj.version_info.date,
        })

    def as_of_url(self, obj):
        return reverse('pages:tags-as_of_date', kwargs={
            'slug': self.page(obj).pretty_slug,
            'region': self.page(obj).region.slug,
            'date': obj.version_info.date,
        })

activity.register(PageTagSetChanges)
예제 #3
0
    def queryset(self, start_at=None):
        if self.region:
            qs = Redirect.versions.filter(region=self.region)
        else:
            qs = Redirect.versions.all()

        if start_at:
            qs = qs.filter(version_info__date__gte=start_at)
        return qs

    def page(self, obj):
        from pages.models import Page

        return Page(slug=obj.source, region=obj.region, name=obj.source.capitalize())

    def title(self, obj):
        return _("Redirect %(objsrc)s --> %(objdest)s") % {"objsrc": obj.source, "objdest": obj.destination}

    def diff_url(self, obj):
        return reverse(
            "redirects:compare-dates",
            kwargs={"slug": obj.source, "region": obj.region.slug, "date1": obj.version_info.date},
        )

    def as_of_url(self, obj):
        # Don't bother.  Just return the source URL.
        return reverse("pages:show", kwargs={"slug": obj.source, "region": obj.region.slug})


activity.register(RedirectChanges)
예제 #4
0
    def queryset(self, start_at=None):
        if self.region:
            qs = MapData.versions.filter(region=self.region)
        else:
            qs = MapData.versions.all()

        if start_at:
            qs = qs.filter(version_info__date__gte=start_at)
        return qs

    def title(self, obj):
        return _('Map for "%s"') % obj.page.name


activity.register(MapChanges)


class MapChangesFeed(ChangesOnItemFeed):
    def get_object(self, request, region='', slug=''):
        self.setup_region(region)

        # TODO: Break out this MapData-get-page pattern into a function.
        # Non-DRY.
        page = Page(slug=slugify(slug), region=self.region)
        latest_page = page.versions.most_recent()
        # Need to set the pk on the dummy page for correct MapData lookup.
        page.pk = latest_page.id
        page.name = latest_page.name

        obj = MapData(page=page, region=self.region)
예제 #5
0
    def queryset(self, start_at=None):
        if self.region:
            qs = Page.versions.filter(region=self.region)
        else:
            qs = Page.versions.all()

        if start_at:
            qs = qs.filter(version_info__date__gte=start_at)

        return qs.defer('content')

    def page(self, obj):
        return obj

activity.register(PageChanges)


class PageFileChanges(ActivityForModel):
    classname = 'file'

    def queryset(self, start_at=None):
        if self.region:
            qs = PageFile.versions.filter(region=self.region)
        else:
            qs = PageFile.versions.all()

        if start_at:
            qs = qs.filter(version_info__date__gte=start_at)
        return qs
예제 #6
0
    classname = 'map'

    def queryset(self, start_at=None):
        if self.region:
            qs = MapData.versions.filter(region=self.region)
        else:
            qs = MapData.versions.all()

        if start_at:
            qs = qs.filter(version_info__date__gte=start_at)
        return qs

    def title(self, obj):
        return _('Map for "%s"') % obj.page.name

activity.register(MapChanges)


class MapChangesFeed(ChangesOnItemFeed):
    def get_object(self, request, region='', slug=''):
        self.setup_region(region)

        # TODO: Break out this MapData-get-page pattern into a function.
        # Non-DRY.
        page = Page(slug=slugify(slug), region=self.region)
        latest_page = page.versions.most_recent()
        # Need to set the pk on the dummy page for correct MapData lookup.
        page.pk = latest_page.id
        page.name = latest_page.name

        obj = MapData(page=page, region=self.region)
예제 #7
0
        if self.region:
            qs = Redirect.versions.filter(region=self.region)
        else:
            qs = Redirect.versions.all()

        if start_at:
            qs = qs.filter(version_info__date__gte=start_at)
        return qs

    def page(self, obj):
        from pages.models import Page

        return Page(slug=obj.source, region=obj.region, name=obj.source.capitalize())

    def title(self, obj):
        return _('Redirect %(objsrc)s --> %(objdest)s') % {
                'objsrc':obj.source, 'objdest':obj.destination}

    def diff_url(self, obj):
        return reverse('redirects:compare-dates', kwargs={
            'slug': obj.source,
            'region': obj.region.slug,
            'date1': obj.version_info.date,
        })

    def as_of_url(self, obj):
        # Don't bother.  Just return the source URL.
        return reverse('pages:show', kwargs={'slug': obj.source, 'region': obj.region.slug})

activity.register(RedirectChanges)