예제 #1
0
 def _get_absolute_url():
     try:
         site = current_site()
         if site == self.section.site:
             return reverse_app(
                 (
                     f"{site.id}-blog-{self.namespace.name}-{self.category}",
                     f"{site.id}-blog-{self.namespace.name}",
                     f"{site.id}-blog-{self.category}",
                     f"{site.id}-blog",
                 ),
                 "article-detail",
                 kwargs={"slug": self.slug},
                 languages=[self.language_code],
             )
         with set_current_site(self.section.site):
             site = self.section.site
             return ("//" + self.section.site.host + reverse_app(
                 [
                     f'{site.id}-blog-{self.namespace.name}-{self.category or ""}',
                     f"{site.id}-blog-{self.namespace.name}",
                     f'{site.id}-blog-{self.category or ""}',
                     f"{site.id}-blog",
                 ],
                 "article-detail",
                 urlconf=apps_urlconf(),
                 kwargs={"slug": self.slug},
                 languages=[self.language_code],
             ))
     except NoReverseMatch:
         return "#"
예제 #2
0
 def get_absolute_url(self):
     try:
         site = current_site()
         return reverse_app([f"{site.id}-people"],
                            "person-detail",
                            kwargs={"pk": self.pk})
     except NoReverseMatch:
         return ""
예제 #3
0
    def get_absolute_url(self, *args, **kwargs):

        if self.redirect_to_url or self.redirect_to_page:
            return self.redirect_to_url or self.redirect_to_page.get_absolute_url(
            )

        site = current_site()
        if site == self.site:
            return super().get_absolute_url(*args, **kwargs)
        return "//" + self.site.host + super().get_absolute_url()
예제 #4
0
 def get_absolute_url(self):
     site = current_site()
     try:
         return (
             reverse_app(
                 [f"{site.id}-glossary"], "glossary", languages=[self.language_code],
             )
             + f"#{self.slug}"
         )
     except:
         return "#"
예제 #5
0
 def get_absolute_url(self):
     site = current_site()
     try:
         return reverse_app(
             (str(site.id) + "-categories",),
             "category-detail",
             languages=[self.language_code],
             kwargs={"slug": self.slug},
         )
     except NoReverseMatch:
         return "#"
예제 #6
0
 def get_absolute_url(self):
     site = current_site()
     if self.section.site == site:
         return reverse_app(
             (f"{self.section.site_id}-people", ),
             "team-detail",
             kwargs={"pk": self.pk},
         )
     with set_current_site(self.section.site):
         return ("//" + self.section.site.host + reverse_app(
             [f"{self.section.site.id}-people"],
             "team-detail",
             urlconf=apps_urlconf(),
             kwargs={"pk": self.pk},
         ))
예제 #7
0
 def get_absolute_url(self):
     try:
         site = current_site()
         if not self.section or site == self.section.site:
             return reverse_app([f"{site.pk}-events"],
                                "location-detail",
                                kwargs={"slug": self.slug})
         with set_current_site(self.section.site):
             return ("//" + self.section.site.host + reverse_app(
                 [f"{self.section.site.id}-events"],
                 "location-detail",
                 urlconf=apps_urlconf(),
                 kwargs={"slug": self.slug},
             ))
     except NoReverseMatch:
         return "#"
예제 #8
0
def get_event_list(plugin):
    if plugin.events.exists():
        return plugin.events.all()
    from juso.events.models import Event

    events = Event.objects.filter(language_code=plugin.language_code,
                                  end_date__gte=timezone.now())

    if plugin.category:
        events = events.filter(category=plugin.category)

    if plugin.sections.exists():
        events = events.filter(section__in=plugin.sections.all())
    else:
        events = events.filter(section__site=current_site())

    return events[:plugin.count]
예제 #9
0
 def _get_absolute_url():
     try:
         site = current_site()
         if site == self.section.site:
             return reverse_app(
                 [
                     f"{site.id}-events-{self.category}",
                     f"{site.id}-events",
                 ],
                 "event-detail",
                 urlconf=apps_urlconf(),
                 kwargs={
                     "slug": self.slug,
                     "day": self.start_date.day,
                     "month": self.start_date.month,
                     "year": self.start_date.year,
                 },
                 languages=[self.language_code],
             )
         with set_current_site(self.section.site):
             return ("//" + self.section.site.host + reverse_app(
                 [
                     f"{self.section.site.id}-events-{self.category}",
                     f"{self.section.site.id}-events",
                 ],
                 "event-detail",
                 urlconf=apps_urlconf(),
                 kwargs={
                     "slug": self.slug,
                     "day": self.start_date.day,
                     "month": self.start_date.month,
                     "year": self.start_date.year,
                 },
                 languages=[self.language_code],
             ))
     except NoReverseMatch:
         return "#"
예제 #10
0
 def active(self, *, site=None):
     return self.filter(is_active=True, site=site or current_site())
예제 #11
0
 def get_absolute_url(self, *args, **kwargs):
     site = current_site()
     if site == self.site:
         return super().get_absolute_url(*args, **kwargs)
     return '//' + self.site.host + super().get_absolute_url()