Dry url issue69 #71
Dry url issue69 #71
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
from django.conf.urls.defaults import patterns, include, url | ||
|
||
urlpatterns = patterns('', | ||
urlpatterns = patterns('contacts_and_people.views', | ||
|
||
# person | ||
(r"^person/(?P<slug>[-\w]+)/(?P<active_tab>[-\w]*)/?$", "contacts_and_people.views.person"), | ||
(r"^person/(?P<slug>[-\w]+)/?$", "person", {}, "contact_person"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the advantage of splitting up a pattern that could catch URLs with or without a tab into two different ones? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there were only one pattern i.e.
then calling
would return
would return OTH calling
would return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, good, I think I understand this now. |
||
(r"^person/(?P<slug>[-\w]+)/(?P<active_tab>[-\w]*)/?$", "person", {}, "contact_person_tab"), | ||
|
||
# place | ||
(r"^place/(?P<slug>[-\w]+)/(?P<active_tab>[-\w]*)/?$", "contacts_and_people.views.place"), | ||
(r"^place/(?P<slug>[-\w]+)/?$", "place", {}, "contact_place"), | ||
(r"^place/(?P<slug>[-\w]+)/(?P<active_tab>[-\w]*)/?$", "place", {}, "contact_place_tab"), | ||
|
||
# lists of people in an entity | ||
(r"^people/(?P<slug>[-\w]+)/(?P<letter>\w)/$", "contacts_and_people.views.people"), | ||
(r"^people/(?P<slug>[-\w]+)/$", "contacts_and_people.views.people"), | ||
(r"^people/(?P<slug>[-\w]+)/$", "people", {}, "contact_people"), | ||
(r"^people/(?P<slug>[-\w]+)/(?P<letter>\w)/$", "people", {}, "contact_people_letter"), | ||
|
||
# main contacts & people page | ||
(r'^contact/(?P<slug>[-\w]+)/$', "contacts_and_people.views.contacts_and_people"), # non-base entities | ||
(r'^contact/$', "contacts_and_people.views.contacts_and_people"), # base entity only | ||
(r'^contact/(?P<slug>[-\w]+)/$', "contacts_and_people", {}, "contact"), # non-base entities | ||
(r'^contact/$', "contacts_and_people", {}, "contact_base"), # base entity only | ||
|
||
# news, events, vacancies, studentships | ||
(r'^', include('news_and_events.urls')), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
from django.conf.urls.defaults import * | ||
from news_and_events import views | ||
# from news_and_events.views import NewsAndEventsViews | ||
|
||
urlpatterns = patterns('', | ||
urlpatterns = patterns('news_and_events.views', | ||
|
||
# news and events items | ||
url(r"^news/(?P<slug>[-\w]+)/$", views.newsarticle, name="newsarticle"), | ||
url(r"^event/(?P<slug>[-\w]+)/$", views.event, name="event"), | ||
url(r"^news/(?P<slug>[-\w]+)/$", "newsarticle", {}, "news" ), | ||
url(r"^event/(?P<slug>[-\w]+)/$", "event", {}, "event"), | ||
|
||
# named entities' news and events | ||
url(r'^news-archive/(?:(?P<slug>[-\w]+)/)?$', views.news_archive, name="news_archive"), | ||
url(r'^previous-events/(?:(?P<slug>[-\w]+)/)?$', views.previous_events, name="previous_events"), | ||
url(r'^forthcoming-events/(?:(?P<slug>[-\w]+)/)?$', views.all_forthcoming_events, name="forthcoming_event"), | ||
url(r"^news-and-events/(?:(?P<slug>[-\w]+)/)?$", views.news_and_events, name="news_and_events"), | ||
url(r'^news-archive/?$', "news_archive", {}, "news-archive_base"), | ||
url(r'^news-archive/(?:(?P<slug>[-\w]+)/)?$', "news_archive", {}, "news-archive"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there an advantage here in replacing a single pattern with two - one that can catch slugs and one that doesn't? |
||
url(r'^previous-events/?$', "previous_events", {}, "previous-events_base"), | ||
url(r'^previous-events/(?:(?P<slug>[-\w]+)/)?$', "previous_events", {}, "previous-events"), | ||
url(r'^forthcoming-events/?$', "all_forthcoming_events", {}, "forthcoming-events_base"), | ||
url(r'^forthcoming-events/(?:(?P<slug>[-\w]+)/)?$', "all_forthcoming_events", {}, "forthcoming-events"), | ||
url(r"^news-and-events/?$", "news_and_events", {}, "news-and-events_base"), | ||
url(r"^news-and-events/(?:(?P<slug>[-\w]+)/)?$", "news_and_events", {}, "news-and-events"), | ||
) | ||
#(r"^entity/(?P<slug>[-\w]+)/news/$", "news_and_events.views.news"), # in development | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
from django.conf.urls.defaults import patterns | ||
|
||
urlpatterns = patterns('', | ||
urlpatterns = patterns('vacancies_and_studentships.views', | ||
|
||
# vacancies and studentships | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These need some more names on the patterns - for example, name="archived-vacancies_base" and so on. I will also rationalise hyphens and underscores - "archived-vacancies_base" looks messy. |
||
(r"^vacancy/(?P<slug>[-\w]+)/$", "vacancies_and_studentships.views.vacancy"), | ||
(r"^studentship/(?P<slug>[-\w]+)/$", "vacancies_and_studentships.views.studentship"), | ||
(r"^vacancy/(?P<slug>[-\w]+)/$", "vacancy", {}, "vacancy"), | ||
(r"^studentship/(?P<slug>[-\w]+)/$", "studentship", {}, "studentship"), | ||
|
||
# named entities' vacancies and studentships | ||
(r"^vacancies-and-studentships/(?P<slug>[-\w]+)/$", "vacancies_and_studentships.views.vacancies_and_studentships"), | ||
|
||
(r'^archived-vacancies/(?P<slug>[-\w]+)/$', "vacancies_and_studentships.views.archived_vacancies"), | ||
(r'^all-open-vacancies/(?P<slug>[-\w]+)/$', "vacancies_and_studentships.views.all_current_vacancies"), | ||
|
||
(r'^archived-studentships/(?P<slug>[-\w]+)/$', "vacancies_and_studentships.views.archived_studentships"), | ||
(r'^all-open-studentships/(?P<slug>[-\w]+)/$', "vacancies_and_studentships.views.all_current_studentships"), | ||
|
||
(r"^vacancies-and-studentships/(?P<slug>[-\w]+)/$", "vacancies_and_studentships", {}, "vacancies-and-studentships"), | ||
# base entity's vacancies and studentships | ||
(r'^vacancies-and-studentships/$', "vacancies_and_studentships.views.vacancies_and_studentships"), | ||
(r'^vacancies-and-studentships/$', "vacancies_and_studentships", {}, "vacancies-and-studentships_base"), | ||
|
||
(r'^archived-vacancies/(?P<slug>[-\w]+)/$', "archived_vacancies"), | ||
(r'^all-open-vacancies/(?P<slug>[-\w]+)/$', "all_current_vacancies"), | ||
|
||
(r'^archived-vacancies/$', "vacancies_and_studentships.views.archived_vacancies"), | ||
(r'^all-open-vacancies/$', "vacancies_and_studentships.views.all_current_vacancies"), | ||
(r'^archived-vacancies/$', "archived_vacancies"), | ||
(r'^all-open-vacancies/$', "all_current_vacancies"), | ||
|
||
(r'^archived-studentships/(?P<slug>[-\w]+)/$', "archived_studentships"), | ||
(r'^all-open-studentships/(?P<slug>[-\w]+)/$', "all_current_studentships"), | ||
|
||
(r'^archived-studentships/$', "vacancies_and_studentships.views.archived_studentships"), | ||
(r'^all-open-studentships/$', "vacancies_and_studentships.views.all_current_studentships"), | ||
(r'^archived-studentships/$', "archived_studentships"), | ||
(r'^all-open-studentships/$', "all_current_studentships"), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I understand the purpose of this. Since, if
kind in kinds
isFalse
we will use"/%s/" % kind
anyway, and since that will work just the same even ifkind in kinds
isTrue
, why do we need it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
kind
is not in the list then it probably wont get properreverse
so it has to have fallback"/%s/" % kind
. I didn't know if and when you'll pull this code into origin repo and if you define some other kind I still want that part to work without debugging. Looking to it now it would be better to write:If and when choose to use reverse everywhere then it is not needed anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will be better to move towards using
reverse
everywhere.If I understand correctly,
reverse
will match all url patterns in the system, so as long as - for example - the Publications application we use has named url patterns that conform to the same scheme it will work with them too.