Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
FAST
project
fast-project-list
Commits
95c62049
Commit
95c62049
authored
Oct 07, 2020
by
Mirko Vucicevich
Browse files
Added slug field and made default project URLS use slugs
parent
8c9dfa2e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
4 deletions
+45
-4
projector/admin.py
projector/admin.py
+3
-1
projector/migrations/0032_auto_20201007_1338.py
projector/migrations/0032_auto_20201007_1338.py
+32
-0
projector/models/projects.py
projector/models/projects.py
+4
-1
projector/static/style.css
projector/static/style.css
+1
-1
projector/templates/index.html
projector/templates/index.html
+1
-1
projector/urls.py
projector/urls.py
+4
-0
No files found.
projector/admin.py
View file @
95c62049
...
...
@@ -51,7 +51,7 @@ class ProjectAdmin(admin.ModelAdmin):
list_display
=
[
'title'
,
'url'
,
'get_groups'
]
fieldsets
=
[
(
'Project Information'
,
{
'fields'
:
[
'title'
,
'icon'
,
'tagline'
,
'description'
,
'url'
,
'project_created'
]
'fields'
:
[
'title'
,
'slug'
,
'icon'
,
'tagline'
,
'description'
,
'url'
,
'project_created'
]
}),
(
'Project Details'
,
{
'fields'
:
[
'scope'
,
'technologies'
,
'groups'
]}),
(
'Gitlab Integration'
,
{
...
...
@@ -61,6 +61,8 @@ class ProjectAdmin(admin.ModelAdmin):
}),
]
prepopulated_fields
=
{
'slug'
:
(
"title"
,)}
filter_horizontal
=
[
'technologies'
,
'groups'
]
inlines
=
[
ContributorInline
,
ContactInline
,
NoticeInline
]
...
...
projector/migrations/0032_auto_20201007_1338.py
0 → 100644
View file @
95c62049
# Generated by Django 2.2.16 on 2020-10-07 17:38
from
django.db
import
migrations
,
models
from
django.utils.text
import
slugify
def
forward_func
(
apps
,
schema_editor
):
Project
=
apps
.
get_model
(
'projector'
,
'Project'
)
for
p
in
Project
.
objects
.
all
():
slug
=
slugify
(
p
.
title
)
existing_similar
=
Project
.
objects
.
filter
(
slug__startswith
=
slug
).
count
()
if
existing_similar
>
0
:
slug
=
'{}{}'
.
format
(
slug
,
existing_similar
)
p
.
slug
=
slug
p
.
save
()
def
reverse_func
(
apps
,
schema_editor
):
pass
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'projector'
,
'0031_auto_20191119_0721'
),
]
operations
=
[
migrations
.
RunPython
(
forward_func
,
reverse_func
),
migrations
.
AlterField
(
model_name
=
'project'
,
name
=
'slug'
,
field
=
models
.
SlugField
(
max_length
=
250
,
unique
=
True
),
),
]
projector/models/projects.py
View file @
95c62049
...
...
@@ -16,7 +16,10 @@ class Project(models.Model):
null
=
True
,
)
title
=
models
.
CharField
(
max_length
=
250
)
slug
=
models
.
SlugField
(
max_length
=
250
,
blank
=
True
)
slug
=
models
.
SlugField
(
max_length
=
250
,
unique
=
True
,
help_text
=
"Must be unique. Used for URLs"
)
tagline
=
models
.
CharField
(
max_length
=
100
,
help_text
=
"Short, catchy sentence about the project"
...
...
projector/static/style.css
View file @
95c62049
...
...
@@ -46,7 +46,7 @@ body {
}
.main
{
padding-top
:
68px
;
padding-top
:
4rem
;
}
...
...
projector/templates/index.html
View file @
95c62049
...
...
@@ -41,7 +41,7 @@
<tbody>
{% for project in projects %}
<tr>
<th
scope=
"row"
><a
href=
"{% url 'detail' project.
id
%}"
>
{{ project.title }}
</a></th>
<th
scope=
"row"
><a
href=
"{% url 'detail' project.
slug
%}"
>
{{ project.title }}
</a></th>
<td>
{{ project.tagline }}
</td>
<td>
{% for group in project.groups.all %}
...
...
projector/urls.py
View file @
95c62049
...
...
@@ -27,9 +27,13 @@ except:
urlpatterns
=
[
path
(
''
,
include
(
custom_url_patterns
)),
path
(
''
,
views
.
IndexView
.
as_view
(),
name
=
'index'
),
# Until we deprecate PK, both int and PK work :)
path
(
'<int:pk>/'
,
views
.
DetailView
.
as_view
(),
name
=
'detail'
),
path
(
'<int:pk>/json'
,
project_json_view
,
name
=
'json-detail'
),
path
(
'<int:pk>/send-message'
,
send_message
,
name
=
'send-message'
),
path
(
'<slug:slug>/'
,
views
.
DetailView
.
as_view
(),
name
=
'detail'
),
path
(
'<slug:slug>/json'
,
project_json_view
,
name
=
'json-detail'
),
path
(
'<slug:slug>/send-message'
,
send_message
,
name
=
'send-message'
),
path
(
'about/'
,
views
.
about
,
name
=
'about'
),
path
(
'admin/'
,
admin
.
site
.
urls
),
]
+
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
...
...
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