Skip to content
Browse files

Merge pull request #106 from evildmp/merge-darbula-issue69

Merge darbula issue69
  • Loading branch information...
2 parents 4975d92 + eb6a8c8 commit 7823a9e0f553dd355e99256304c967d8d743f164 @evildmp committed Jul 24, 2013
View
3 arkestra_utilities/import_free_model_mixins.py
@@ -1,4 +1,5 @@
-# this file exists to help avoid circular imports
+# this file exists to help avoid circular imports - it imports nothing from
+# Arkestra
from django.db import models
View
23 arkestra_utilities/mixins.py
@@ -1,40 +1,51 @@
from django.db import models
+from django.core.urlresolvers import reverse
from links.models import ExternalLink
class URLModelMixin(models.Model):
+ # for models that can have external (hosted elsewhere) items
class Meta:
abstract = True
- # url fields
+ # field no longer used, to be deleted
url = models.URLField(null=True, blank=True, verify_exists=True,
- help_text=u"To be used <strong>only</strong> for external items. Use with caution!")
+ help_text=u"Use <strong>only</strong> for external items.")
+
+ # url fields
external_url = models.ForeignKey(ExternalLink,
related_name="%(class)s_item",
on_delete=models.PROTECT,
blank=True, null=True,
help_text=u"Select an item from the External Links database."
)
- slug = models.SlugField(unique=True, max_length=60, blank=True, help_text=u"Do not meddle with this unless you know exactly what you're doing!", error_messages={"unique": "unique"})
+ slug = models.SlugField(unique=True, max_length=60, blank=True,
+ help_text=u"Do not meddle with this unless you know exactly what you're doing!",
+ error_messages={"unique": "unique"}
+ )
def __unicode__(self):
return self.title
def get_absolute_url(self):
if self.external_url:
return self.external_url.url
+ elif self.url_path in ["news","event","vacancy","studentship"]:
+ return reverse(self.url_path,kwargs={"slug":self.slug})
else:
return "/%s/%s/" % (self.url_path, self.slug)
class LocationModelMixin(models.Model):
+ # provides location fields, for people, contacts, events, etc
class Meta:
abstract = True
- # location fields
- precise_location = models.CharField(help_text=u"Precise location <em>within</em> the building, for visitors",
+ precise_location = models.CharField(
+ help_text=u"Location <em>within</em> the building, for visitors",
max_length=255, null=True, blank=True)
- access_note = models.CharField(help_text = u"Notes on access/visiting hours/etc",
+ access_note = models.CharField(
+ help_text = u"Notes on access/visiting hours/etc",
max_length=255, null=True, blank=True)
View
45 contacts_and_people/models.py
@@ -8,6 +8,7 @@
from django.contrib.auth.models import User
from django.template.defaultfilters import slugify
from django.conf import settings
+from django.core.urlresolvers import reverse, NoReverseMatch
from cms.models import Page, CMSPlugin
from cms.models.fields import PlaceholderField
@@ -53,18 +54,22 @@ def get_by_natural_key(self, slug):
return self.get(slug=slug)
class Building(models.Model):
- """Each Building is on a Site."""
+ # the Building model should really be named Place
objects=BuildingManager()
name = models.CharField(max_length=100, null=True, blank=True)
number = models.CharField(max_length=10, null=True, blank=True)
- street = models.CharField("Street name", max_length=100, null = True, blank=True)
+ street = models.CharField(
+ "Street name", max_length=100,
+ null = True, blank=True
+ )
additional_street_address = models.CharField(help_text=u"If required",
max_length=100, null=True, blank=True)
postcode = models.CharField(max_length=9, null=True, blank=True)
site = models.ForeignKey(Site,
on_delete=models.PROTECT,
related_name="place")
- slug = models.SlugField(blank=True, help_text=u"Please leave blank/amend only if required",
+ slug = models.SlugField(blank=True,
+ help_text=u"Please leave blank/amend only if required",
max_length=255, null=True, unique=True)
image = FilerImageField(on_delete=models.SET_NULL,
null=True, blank=True)
@@ -110,7 +115,7 @@ def __unicode__(self):
def get_absolute_url(self):
- return "/place/%s/" % self.slug
+ return reverse("contact_place", kwargs={"slug":self.slug})
def save(self):
if not self.slug or self.slug == '':
@@ -330,9 +335,9 @@ def get_absolute_url(self):
if self.external_url:
return self.external_url.url
elif self.get_website:
- return "/contact/%s/" % self.slug
+ return reverse("contact-entity", kwargs={"slug":self.slug})
else:
- return "/contact/"
+ return reverse("contact-entity-base")
@property
def _get_real_ancestor(self):
@@ -421,16 +426,27 @@ def get_website_url(self):
def get_related_info_page_url(self, kind):
"""
- Returns a URL not for the entity, but for its /contact page, /news-and-events, or whatever.
+ Returns a URL not for the entity, but for its /contact page,
+ /news-and-events, or whatever.
- If the entity is the base entity, doesn't add the entity slug to the URL
+ If the entity is the base entity, doesn't add the entity slug to
+ the URL
"""
+ # external entities don't have info pages
if self.external_url:
return ""
+ # info pages for base entity
elif self == Entity.objects.base_entity():
- return "/%s/" % kind
+ try:
+ return reverse(kind+"_base")
+ except NoReverseMatch:
+ return "/%s/" % kind
+ # info pages for other entities
else:
- return "/%s/%s/" % (kind, self.slug)
+ try:
+ return reverse(kind,kwargs={"slug":self.slug})
+ except NoReverseMatch:
+ return "/%s/%s/" % (kind, self.slug)
def get_template(self):
"""
@@ -630,11 +646,10 @@ def __unicode__(self):
return u" ".join(name_part for name_part in [unicode(title), self.given_name, self.surname] if name_part)
def get_absolute_url(self):
- if self.active:
- if self.external_url:
- return self.external_url.url
- else:
- return "/person/%s/" % self.slug
+ if self.external_url:
+ return self.external_url.url
+ else:
+ return reverse("contact-person", kwargs={"slug":self.slug})
@property
def get_role(self):
View
36 contacts_and_people/templates/contacts_and_people/entity_contacts_and_people.html
@@ -42,22 +42,22 @@
{% endfor %}
{% endfor %}
</dl>
- </div>
- {% endif %}
- {% if initials_list %}
- <h{{ IN_BODY_HEADING_LEVEL }}>All people A-Z by surname</h{{ IN_BODY_HEADING_LEVEL }}>
- <ul class= "index">
- {% for initial in initials_list %}
- <li><a href="/people/{{ entity.slug }}/{{initial|lower|urlencode}}/">{{ initial }}</a></li>
- {% endfor %}
- </ul>
- {% endif %}
- {% if people %}
- <h{{ IN_BODY_HEADING_LEVEL }}>{{ people_list_heading }}</h{{ IN_BODY_HEADING_LEVEL }}>
- {% include "includes/people_with_roles.html" %}
- {% endif %}
- </div>
- {% endif %}
- </div>
-
+ </div>
+ {% endif %}
+ {% if initials_list %}
+ <h{{ IN_BODY_HEADING_LEVEL }}>All people A-Z by surname</h{{ IN_BODY_HEADING_LEVEL }}>
+ <ul class= "index">
+ {% for initial in initials_list %}
+ <li><a href="{% url contact-people-letter entity.slug,initial|lower %}">{{ initial }}</a></li>
+ {% endfor %}
+ </ul>
+ {% endif %}
+ {% if people %}
+ <h{{ IN_BODY_HEADING_LEVEL }}>{{ people_list_heading }}</h{{ IN_BODY_HEADING_LEVEL }}>
+ {% include "includes/people_with_roles.html" %}
+ {% endif %}
+ </div>
+ {% endif %}
+ </div>
+
{% endblock arkestra_content %}
View
8 contacts_and_people/templates/includes/people_list_with_index.html
@@ -5,18 +5,18 @@
Lists members of an entity - either all people by surname, or surnames beginning {{ letter }}.
{% endcomment %}
-{% load entity_tags %}
+{% load i18n entity_tags %}
<div class="row columns2">
<div class="column firstcolumn">
- <h{{ IN_BODY_HEADING_LEVEL }} style="clear:both">{% if letter %}People: surnames beginning {{letter|upper}}{% else %}All people by surname{% endif %}</h{{ IN_BODY_HEADING_LEVEL }}>
+ <h{{ IN_BODY_HEADING_LEVEL }} style="clear:both">{% if letter %}{% trans "People: surnames beginning" %} {{letter|upper}}{% else %}{% trans "All people by surname" %}{% endif %}</h{{ IN_BODY_HEADING_LEVEL }}>
{% people_with_roles letter %}
</div>
<div class="column lastcolumn">
{% if initials_list %}
- <h{{ IN_BODY_HEADING_LEVEL }}>Index of people by surname</h{{ IN_BODY_HEADING_LEVEL }}>
+ <h{{ IN_BODY_HEADING_LEVEL }}>{% trans "Index of people by surname" %}</h{{ IN_BODY_HEADING_LEVEL }}>
<ul class="index">
{% for initial in initials_list %}
- <li><a href="/people/{{ entity.slug }}/{{initial|lower}}/">{{ initial }}</a></li>
+ <li><a href="{% url contact-people-letter entity.slug initial|lower %}">{{ initial }}</a></li>
{% endfor %}
</ul>
{% endif %}
View
99 contacts_and_people/tests.py
@@ -1,7 +1,10 @@
from django.test import TestCase
+from django.core.urlresolvers import reverse
from contacts_and_people.models import Site, Person, Building, Entity, Membership
+from links.models import ExternalLink
+
class SiteTests(TestCase):
def setUp(self):
# a geographical Site
@@ -162,7 +165,7 @@ def setUp(self):
self.web_editors.save()
# set up a Person - we will add memberships later in the tests
- self.smith = Person()
+ self.smith = Person(slug="smith")
self.smith.save()
@@ -181,7 +184,29 @@ def test_get_roles(self):
self.school.get_roles_for_members(people),
[self.smith]
)
-
+
+class EntityGetRelatedInfoPageTests(EntityTestObjectsMixin, TestCase):
+
+ def test_external_entity(self):
+ # an external entity can't have any related info pages
+ external_url = ExternalLink(title="Example", url="http://example.com")
+ self.school.external_url = external_url
+ self.assertEquals(
+ self.school.get_related_info_page_url("contact"),
+ ""
+ )
+
+ def test_base_entity_contact(self):
+ self.assertEquals(
+ self.school.get_related_info_page_url("contact"),
+ "/contact/"
+ )
+
+ def test_base_entity_bogus(self):
+ self.assertEquals(
+ self.school.get_related_info_page_url("bogus"),
+ "/bogus/"
+ )
class EntityAddressTests(EntityTestObjectsMixin, TestCase):
def test_get_building_works_when_building_is_assigned(self):
@@ -255,6 +280,12 @@ class PersonTests(EntityTestObjectsMixin, TestCase):
circumstances
"""
+ def test_person_get_absolute_url(self):
+ self.assertEquals(
+ self.smith.get_absolute_url(),
+ "/person/smith/"
+ )
+
def test_person_with_no_memberships(self):
# smith has no Memberships
self.assertEquals(list(self.smith.real_entity_memberships), [])
@@ -360,4 +391,66 @@ def test_person_with_better_entity_membership(self):
self.assertEquals(self.smith.get_building, self.main_building)
self.assertEquals(self.smith.get_full_address, [self.school, u'Main Building', u"St Mary's Street", u'Cardiff'])
# check that his membership of school has been downgraded by the save()
- self.assertEquals(Membership.objects.get(pk=smith_school_membership.pk).importance_to_person, 4)
+ self.assertEquals(
+ Membership.objects.get(
+ pk=smith_school_membership.pk
+ ).importance_to_person,
+ 4
+ )
+
+
+class ReverseURLsTests(TestCase):
+ def test_person_reverse_url(self):
+ self.assertEqual(
+ reverse("contact-person", kwargs={"slug": "some-slug"}),
+ "/person/some-slug/"
+ )
+
+ def test_person_tab_reverse_url(self):
+ self.assertEqual(
+ reverse(
+ "contact-person-tab",
+ kwargs={"slug": "some-slug", "active_tab": "yibbers"}),
+ "/person/some-slug/yibbers/"
+ )
+
+ def test_place_reverse_url(self):
+ self.assertEqual(
+ reverse("contact-place", kwargs={"slug": "some-slug"}),
+ "/place/some-slug/"
+ )
+
+ def test_place_tab_reverse_url(self):
+ self.assertEqual(
+ reverse(
+ "contact-place-tab",
+ kwargs={"slug": "some-slug", "active_tab": "yibbers"}),
+ "/place/some-slug/yibbers/"
+ )
+
+ def test_contact_people_reverse_url(self):
+ self.assertEqual(
+ reverse("contact-people", kwargs={"slug": "some-slug"}),
+ "/people/some-slug/"
+ )
+
+ def test_contact_people_letter_reverse_url(self):
+ self.assertEqual(
+ reverse(
+ "contact-people-letter",
+ kwargs={"slug": "some-slug", "letter": "w"}),
+ "/people/some-slug/w/"
+ )
+
+ def test_contact_entity_reverse_url(self):
+ self.assertEqual(
+ reverse("contact-entity", kwargs={"slug": "some-slug"}),
+ "/contact/some-slug/"
+ )
+
+ def test_contact_base_entity_reverse_url(self):
+ self.assertEqual(
+ reverse("contact-entity-base"),
+ "/contact/"
+ )
+
View
32 contacts_and_people/urls.py
@@ -1,20 +1,27 @@
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"),
+ url(r"^person/(?P<slug>[-\w]+)/$", "person", name="contact-person"),
+ url(r"^person/(?P<slug>[-\w]+)/(?P<active_tab>[-\w]*)/$", "person",
+ name="contact-person-tab"),
# place
- (r"^place/(?P<slug>[-\w]+)/(?P<active_tab>[-\w]*)/?$", "contacts_and_people.views.place"),
+ url(r"^place/(?P<slug>[-\w]+)/$", "place", name="contact-place"),
+ url(r"^place/(?P<slug>[-\w]+)/(?P<active_tab>[-\w]*)/$", "place",
+ name="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"),
+ url(r"^people/(?P<slug>[-\w]+)/$", "people", name="contact-people"),
+ url(r"^people/(?P<slug>[-\w]+)/(?P<letter>\w)/$", "people", name="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
+ # non-base entities
+ url(r'^contact/(?P<slug>[-\w]+)/$', "contacts_and_people",
+ name="contact-entity"),
+ # base entity only
+ url(r'^contact/$', "contacts_and_people", name="contact-entity-base"),
# news, events, vacancies, studentships
(r'^', include('news_and_events.urls')),
@@ -23,14 +30,5 @@
# housekeeping
(r'^', include('housekeeping.urls')),
(r'^', include('arkestra_image_plugin.urls')),
-
-
)
-
- # the old ways
- # (r"^entity/(?P<slug>[-\w]+)/contact/people/(?P<letter>[a-z])/$", "contacts_and_people.views.people"),
- # (r"^entity/(?P<slug>[-\w]+)/contact/people/$", "contacts_and_people.views.people"),
- # (r"^entity/(?P<slug>[-\w]+)/contact/$", "contacts_and_people.views.contacts_and_people"),
- # )
-
-
+
View
2 example/testrunner.py
@@ -13,5 +13,5 @@
'news_and_events',
'vacancies_and_studentships',
'links',
- verbosity=2,
+ # verbosity=2,
)
View
65 news_and_events/tests.py
@@ -4,6 +4,7 @@
from django.conf import settings
from django.contrib.auth.models import User
+from django.core.urlresolvers import reverse
# we're testing the behaviour of a method that uses date-related functions
from datetime import datetime, timedelta
@@ -103,7 +104,71 @@ def test_published_newsarticle_context(self):
self.tootharticle.save()
response = self.client.get('/news/all-about-teeth/')
self.assertEqual(response.context['newsarticle'], self.tootharticle)
+
+
+class ReverseURLsTests(TestCase):
+ def test_newsarticle_reverse_url(self):
+ self.assertEqual(
+ reverse("news", kwargs={"slug": "all-about-teeth"}),
+ "/news/all-about-teeth/"
+ )
+
+ def test_event_reverse_url(self):
+ self.assertEqual(
+ reverse("event", kwargs={"slug": "all-about-teeth"}),
+ "/event/all-about-teeth/"
+ )
+
+ def test_news_archive_base_reverse_url(self):
+ self.assertEqual(
+ reverse("news-archive-base"),
+ "/news-archive/"
+ )
+
+ def test_news_archive_slug_reverse_url(self):
+ self.assertEqual(
+ reverse("news-archive", kwargs={"slug": "some-slug"}),
+ "/news-archive/some-slug/"
+ )
+
+ def test_previous_events_base_reverse_url(self):
+ self.assertEqual(
+ reverse("previous-events-base"),
+ "/previous-events/"
+ )
+
+ def test_previous_events_reverse_url(self):
+ self.assertEqual(
+ reverse("previous-events", kwargs={"slug": "some-slug"}),
+ "/previous-events/some-slug/"
+ )
+
+ def test_forthcoming_events_base_reverse_url(self):
+ self.assertEqual(
+ reverse("forthcoming-events-base"),
+ "/forthcoming-events/"
+ )
+
+ def test_forthcoming_events_reverse_url(self):
+ self.assertEqual(
+ reverse("forthcoming-events", kwargs={"slug": "some-slug"}),
+ "/forthcoming-events/some-slug/"
+ )
+
+ def test_news_and_events_base_reverse_url(self):
+ self.assertEqual(
+ reverse("news-and-events-base"),
+ "/news-and-events/"
+ )
+
+ def test_news_and_events_reverse_url(self):
+ self.assertEqual(
+ reverse("news-and-events", kwargs={"slug": "some-slug"}),
+ "/news-and-events/some-slug/"
+ )
+
+
@override_settings(
CMS_TEMPLATES = (('null.html', "Null"),)
)
View
76 news_and_events/urls.py
@@ -1,18 +1,68 @@
-from django.conf.urls.defaults import *
-from news_and_events import views
-# from news_and_events.views import NewsAndEventsViews
+from django.conf.urls.defaults import patterns, url
-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",
+ name="news"
+ ),
+ url(
+ r"^event/(?P<slug>[-\w]+)/$",
+ "event",
+ name="event"
+ ),
- # 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"),
- )
- #(r"^entity/(?P<slug>[-\w]+)/news/$", "news_and_events.views.news"), # in development
+ # news archives
+ url(
+ r'^news-archive/$',
+ "news_archive",
+ {"slug": None},
+ name="news-archive-base"
+ ),
+ url(
+ r'^news-archive/(?:(?P<slug>[-\w]+)/)$',
+ "news_archive",
+ name="news-archive"
+ ),
+
+ # previous events
+ url(
+ r'^previous-events/$',
+ "previous_events",
+ {"slug": None},
+ name="previous-events-base"
+ ),
+ url(
+ r'^previous-events/(?:(?P<slug>[-\w]+)/)$',
+ "previous_events",
+ name="previous-events"
+ ),
+ # forthcoming events
+ url(
+ r'^forthcoming-events/$',
+ "all_forthcoming_events",
+ {"slug": None},
+ name="forthcoming-events-base"
+ ),
+ url(
+ r'^forthcoming-events/(?:(?P<slug>[-\w]+)/)$',
+ "all_forthcoming_events",
+ name="forthcoming-events"
+ ),
+
+ # main news and events
+ url(
+ r"^news-and-events/$",
+ "news_and_events",
+ {"slug": None},
+ name="news-and-events-base"
+ ),
+ url(
+ r"^news-and-events/(?:(?P<slug>[-\w]+)/)$",
+ "news_and_events",
+ name="news-and-events"
+ ),
+ )
View
8 news_and_events/views.py
@@ -1,5 +1,5 @@
import datetime
-
+from django.utils.translation import ugettext as _
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.http import Http404
@@ -44,11 +44,11 @@ def news_and_events(request, slug):
instance.type = "main_page"
meta = {"description": "Recent news and forthcoming events",}
- title = unicode(entity) + u" news & events"
+ title = unicode(entity) + _(u" news & events")
if MULTIPLE_ENTITY_MODE:
- pagetitle = unicode(entity) + u" news & events"
+ pagetitle = unicode(entity) + _(u" news & events")
else:
- pagetitle = "News & events"
+ pagetitle = _("News & events")
CMSNewsAndEventsPlugin().render(context, instance, None)
context.update({
View
94 vacancies_and_studentships/tests.py
@@ -4,6 +4,7 @@
from django.conf import settings
from django.contrib.auth.models import User
+from django.core.urlresolvers import reverse
# we're testing the behaviour of a method that uses date-related functions
import datetime
@@ -89,7 +90,82 @@ def test_published_vacancy_context(self):
self.toothjob.save()
response = self.client.get('/vacancy/pulling-teeth/')
self.assertEqual(response.context['vacancy'], self.toothjob)
+
+class ReverseURLsTests(TestCase):
+ def test_vacancy_reverse_url(self):
+ self.assertEqual(
+ reverse("vacancy", kwargs={"slug": "tooth-puller"}),
+ "/vacancy/tooth-puller/"
+ )
+
+ def test_studentship_reverse_url(self):
+ self.assertEqual(
+ reverse("studentship", kwargs={"slug": "tooth-puller"}),
+ "/studentship/tooth-puller/"
+ )
+
+ def test_archived_vacancies_base_reverse_url(self):
+ self.assertEqual(
+ reverse("archived-vacancies-base"),
+ "/archived-vacancies/"
+ )
+
+ def test_archived_vacancies_reverse_url(self):
+ self.assertEqual(
+ reverse("archived-vacancies", kwargs={"slug": "some-slug"}),
+ "/archived-vacancies/some-slug/"
+ )
+
+ def test_current_vacancies_base_reverse_url(self):
+ self.assertEqual(
+ reverse("current-vacancies-base"),
+ "/current-vacancies/"
+ )
+
+ def test_current_vacancies_reverse_url(self):
+ self.assertEqual(
+ reverse("current-vacancies", kwargs={"slug": "some-slug"}),
+ "/current-vacancies/some-slug/"
+ )
+
+ def test_archived_studentships_base_reverse_url(self):
+ self.assertEqual(
+ reverse("archived-studentships-base"),
+ "/archived-studentships/"
+ )
+
+ def test_archived_studentships_reverse_url(self):
+ self.assertEqual(
+ reverse("archived-studentships", kwargs={"slug": "some-slug"}),
+ "/archived-studentships/some-slug/"
+ )
+
+ def test_current_studentships_base_reverse_url(self):
+ self.assertEqual(
+ reverse("current-studentships-base"),
+ "/current-studentships/"
+ )
+
+ def test_current_studentships_reverse_url(self):
+ self.assertEqual(
+ reverse("current-studentships", kwargs={"slug": "some-slug"}),
+ "/current-studentships/some-slug/"
+ )
+
+ def test_vacancies_and_studentships_base_reverse_url(self):
+ self.assertEqual(
+ reverse("vacancies-and-studentships-base"),
+ "/vacancies-and-studentships/"
+ )
+
+ def test_vacancies_and_studentships_reverse_url(self):
+ self.assertEqual(
+ reverse("vacancies-and-studentships", kwargs={"slug": "some-slug"}),
+ "/vacancies-and-studentships/some-slug/"
+ )
+
+
@override_settings(
CMS_TEMPLATES = (('null.html', "Null"),)
)
@@ -161,17 +237,17 @@ def test_vacancies_and_studentships_bogus_entity_archived_studentships_url(self)
def test_vacancies_and_studentships_main_all_current_studentships_url(self):
self.school.save()
- response = self.client.get('/all-open-studentships/')
+ response = self.client.get('/current-studentships/')
self.assertEqual(response.status_code, 200)
def test_vacancies_and_studentships_entity_all_current_studentships_url(self):
self.school.save()
- response = self.client.get('/all-open-studentships/medicine/')
+ response = self.client.get('/current-studentships/medicine/')
self.assertEqual(response.status_code, 200)
def test_vacancies_and_studentships_bogus_entity_all_current_studentships_url(self):
self.school.save()
- response = self.client.get('/all-open-studentships/xxx/')
+ response = self.client.get('/current-studentships/xxx/')
self.assertEqual(response.status_code, 404)
# entity vacancies and studentships URLs - no vacancies and studentships pages
@@ -232,19 +308,19 @@ def test_vacancies_and_studentships_no_auto_page_bogus_entity_archived_studentsh
def test_vacancies_and_studentships_no_auto_page_main_all_current_studentships_url(self):
self.school.auto_vacancies_page= False
self.school.save()
- response = self.client.get('/all-open-studentships/')
+ response = self.client.get('/current-studentships/')
self.assertEqual(response.status_code, 404)
def test_vacancies_and_studentships_no_auto_page_entity_all_current_studentships_url(self):
self.school.auto_vacancies_page = False
self.school.save()
- response = self.client.get('/all-open-studentships/medicine/')
+ response = self.client.get('/current-studentships/medicine/')
self.assertEqual(response.status_code, 404)
def test_vacancies_and_studentships_no_auto_page_bogus_entity_all_current_studentships_url(self):
self.school.auto_vacancies_page= False
self.school.save()
- response = self.client.get('/all-open-studentships/xxx/')
+ response = self.client.get('/current-studentships/xxx/')
self.assertEqual(response.status_code, 404)
# entity vacancies and studentships URLs - no entity home page
@@ -305,18 +381,18 @@ def test_vacancies_and_studentships_no_entity_home_page_bogus_entity_archived_st
def test_vacancies_and_studentships_no_entity_home_page_main_all_current_studentships_url(self):
self.school.website = None
self.school.save()
- response = self.client.get('/all-open-studentships/')
+ response = self.client.get('/current-studentships/')
self.assertEqual(response.status_code, 404)
def test_vacancies_and_studentships_no_entity_home_page_entity_all_current_studentships_url(self):
self.school.website = None
self.school.save()
- response = self.client.get('/all-open-studentships/medicine/')
+ response = self.client.get('/current-studentships/medicine/')
self.assertEqual(response.status_code, 404)
def test_vacancies_and_studentships_no_entity_home_page_bogus_entity_all_current_studentships_url(self):
self.school.website = None
self.school.save()
- response = self.client.get('/all-open-studentships/xxx/')
+ response = self.client.get('/current-studentships/xxx/')
self.assertEqual(response.status_code, 404)
View
89 vacancies_and_studentships/urls.py
@@ -1,19 +1,82 @@
from django.conf.urls.defaults import patterns, url
-import views
-urlpatterns = patterns('',
+urlpatterns = patterns('vacancies_and_studentships.views',
- # vacancies and studentships items
- url(r"^vacancy/(?P<slug>[-\w]+)/$", views.vacancy, name="vacancy"),
- url(r"^studentship/(?P<slug>[-\w]+)/$", views.studentship, name="studentship"),
+ # vacancies and studentship items
+ url(
+ r"^vacancy/(?P<slug>[-\w]+)/$",
+ "vacancy",
+ name="vacancy"
+ ),
+ url(
+ r"^studentship/(?P<slug>[-\w]+)/$",
+ "studentship",
+ name="studentship"
+ ),
- # entities' vacancies and studentships
- url(r'^archived-vacancies/(?:(?P<slug>[-\w]+)/)?$', views.archived_vacancies, name="archived_vacancies"),
- url(r'^all-open-vacancies/(?:(?P<slug>[-\w]+)/)?$', views.all_current_vacancies, name="all_current_vacancies"),
+ # archived vacancies
+ url(
+ r'^archived-vacancies/$',
+ "archived_vacancies",
+ {"slug": None},
+ "archived-vacancies-base"
+ ),
+ url(
+ r'^archived-vacancies/(?:(?P<slug>[-\w]+)/)$',
+ "archived_vacancies",
+ name="archived-vacancies"
+ ),
-url(r'^archived-studentships/(?:(?P<slug>[-\w]+)/)?$', views.archived_studentships, name="archived_studentships"),
- url(r"^all-open-studentships/(?:(?P<slug>[-\w]+)/)?$", views.all_current_studentships, name="all_current_studentships"),
+ # all current vacancies
+ url(
+ r'^current-vacancies/$',
+ "all_current_vacancies",
+ {"slug": None},
+ name="current-vacancies-base"
+ ),
+ url(
+ r'^current-vacancies/(?:(?P<slug>[-\w]+)/)$',
+ "all_current_vacancies",
+ name="current-vacancies"
+ ),
-url(r"^vacancies-and-studentships/(?:(?P<slug>[-\w]+)/)?$", views.vacancies_and_studentships, name="vacancies_and_studentships"),
- )
-
+ # archived studentships
+ url(
+ r'^archived-studentships/$',
+ "archived_studentships",
+ {"slug": None},
+ "archived-studentships-base"
+ ),
+ url(
+ r'^archived-studentships/(?:(?P<slug>[-\w]+)/)$',
+ "archived_studentships",
+ name="archived-studentships"
+ ),
+
+ # all current studentships
+ url(
+ r'^current-studentships/$',
+ "all_current_studentships",
+ {"slug": None},
+ "current-studentships-base"
+ ),
+ url(
+ r'^current-studentships/(?:(?P<slug>[-\w]+)/)$',
+ "all_current_studentships",
+ name="current-studentships"
+ ),
+
+ # main vacancies and studentships
+ url(
+ r"^vacancies-and-studentships/$",
+ "vacancies_and_studentships",
+ {"slug": None},
+ "vacancies-and-studentships-base"
+ ),
+ url(
+ r"^vacancies-and-studentships/(?:(?P<slug>[-\w]+)/)$",
+ "vacancies_and_studentships",
+ name="vacancies-and-studentships"
+ ),
+
+)

0 comments on commit 7823a9e

Please sign in to comment.
Something went wrong with that request. Please try again.