Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
roomlist
Commits
90932fdb
Commit
90932fdb
authored
Sep 27, 2016
by
Daniel W Bond
Browse files
modified major object slug field
parent
c280cedf
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
roomlist/accounts/major_fixtures.json
View file @
90932fdb
This diff is collapsed.
Click to expand it.
roomlist/accounts/models.py
View file @
90932fdb
...
...
@@ -23,12 +23,11 @@ class Major(TimeStampedModel):
name
=
models
.
CharField
(
max_length
=
50
)
# I believe the longest is "Government and International Politics"
slug
=
AutoSlugField
(
populate_from
=
'name'
,
unique
=
True
)
# don't fix this just yet-- coincide with end of semester when everyone's
# changing up their accounts anyway
#name_slug = AutoSlugField(populate_from='name') # custom function to delete
# ba/bs/etc
slug
=
AutoSlugField
(
populate_from
=
'name'
,
always_update
=
True
,
unique
=
True
)
# always_update is set to support migrating from previous versions' slugs
# which were originally random characters
# on always_update, the slug is modified whenever the populated_from field changes
# to update from previous versions, call .save() on all existing models
def
first_letter
(
self
):
return
self
.
name
and
self
.
name
[
0
]
or
''
...
...
@@ -40,10 +39,7 @@ class Major(TimeStampedModel):
return
unicode
(
self
.
name
)
def
get_absolute_url
(
self
):
return
reverse
(
'detail_major'
,
kwargs
=
{
'slug'
:
self
.
slug
,
'major'
:
slugify
(
self
.
name
),
})
return
reverse
(
'detail_major'
,
kwargs
=
{
'slug'
:
self
.
slug
})
class
Meta
:
ordering
=
[
'name'
]
...
...
roomlist/accounts/urls.py
View file @
90932fdb
...
...
@@ -17,7 +17,7 @@ urlpatterns = patterns('',
# majors pages
url
(
r
'^majors/$'
,
ListMajors
.
as_view
(),
name
=
'list_majors'
),
url
(
r
'^majors/(?P<slug>[\w-]+)/
(?P<major>[\w-]+)/
$'
,
url
(
r
'^majors/(?P<slug>[\w-]+)/$'
,
DetailMajor
.
as_view
(),
name
=
'detail_major'
),
# student profile pages
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment