Skip to content

Instantly share code, notes, and snippets.

@paltman
Created October 19, 2017 02:15
Show Gist options
  • Save paltman/b8f988c5ec03fe803e173ba2f9c78b78 to your computer and use it in GitHub Desktop.
Save paltman/b8f988c5ec03fe803e173ba2f9c78b78 to your computer and use it in GitHub Desktop.
from django.conf.urls import url, include
from django.urls import reverse
from django.utils import timezone
from pinax.announcements.forms import AnnouncementForm
from .base import ViewConfig as BaseViewConfig
announcement = {
"pk": 1,
"title": "Bacon ipsum dolor amet corned beef beef tri-tip venison",
"publish_start": timezone.now(),
"publish_end": timezone.now(),
"content": "Anim labore doner shank fatback ham enim burgdoggen ipsum pork chop deserunt. Pancetta venison sausage officia sint. Tri-tip hamburger pork chop dolor andouille. Flank pork loin beef ribs, spare ribs bresaola dolore picanha tongue incididunt ham bacon."
}
announcement_list = [
announcement,
announcement,
announcement,
announcement
]
label = "announcement"
title = "Pinax Announcements"
url_namespace = "pinax_announcements"
class ViewConfig(BaseViewConfig):
def resolved_path(self):
return reverse("{}:{}".format(url_namespace, self.name), kwargs=self.pattern_kwargs)
views = [
ViewConfig(
pattern=r"^pinax-announcements/$",
template="pinax/announcements/announcement_list.html",
name="announcement_list",
pattern_kwargs={},
announcement_list=announcement_list
),
# Rest of ViewConfig's cut for brevity
]
urlpatterns = [
view.url()
for view in views
]
url = url(r"", include(
"pinax_theme_tester.configs.announcements", namespace=url_namespace)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment