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
Michael R Lundquist
whats-open
Commits
80b88a77
Commit
80b88a77
authored
Jan 29, 2019
by
David Haynes
🙆
Browse files
Small touchups to the admin
- Making things look nice
parent
133462d1
Changes
6
Hide whitespace changes
Inline
Side-by-side
docker-startup.sh
View file @
80b88a77
...
...
@@ -9,5 +9,5 @@ export WOPEN_SECRET_KEY=$(dd if=/dev/urandom count=100 | tr -dc "A-Za-z0-9" | fo
python whats-open/manage.py makemigrations
python whats-open/manage.py makemigrations api
python whats-open/manage.py migrate
echo
"from django.contrib.auth.models import User; User.objects.filter(
email
='
$WOPEN_SUPERUSER$WOPEN_EMAIL_DOMAIN
').delete(); User.objects.create_superuser('
$WOPEN_SUPERUSER$WOPEN_EMAIL_DOMAIN
', '
$WOPEN_SUPERUSER
', 'admin')"
| python whats-open/manage.py shell
echo
"from django.contrib.auth.models import User; User.objects.filter(
username
='
$WOPEN_SUPERUSER$WOPEN_EMAIL_DOMAIN
').delete(); User.objects.create_superuser('
$WOPEN_SUPERUSER$WOPEN_EMAIL_DOMAIN
', '
$WOPEN_SUPERUSER
', 'admin')"
| python whats-open/manage.py shell
python whats-open/manage.py runserver 0.0.0.0:8000
whats-open/api/admin.py
View file @
80b88a77
...
...
@@ -113,6 +113,7 @@ class FacilityAdmin(admin.ModelAdmin):
# Allow filtering by the following fields
list_filter
=
[
"facility_category"
,
"facility_location"
]
list_display
=
(
"facility_name"
,
"main_schedule"
,
"modified"
)
# Modify the rendered layout of the "create a new facility" page
# We are basically reordering things to look nicer to the user here
fieldsets
=
(
...
...
@@ -200,3 +201,7 @@ admin.site.register(Location, OSMGeoAdmin)
# Use the default ModelAdmin interface for these
admin
.
site
.
register
(
Category
)
admin
.
site
.
register
(
Alert
)
admin
.
site
.
site_header
=
"What's Open API"
admin
.
site
.
site_title
=
"What's Open API"
admin
.
site
.
index_title
=
"Admin"
whats-open/api/migrations/0005_auto_20190129_1215.py
0 → 100644
View file @
80b88a77
# Generated by Django 2.0.10 on 2019-01-29 17:15
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'api'
,
'0004_auto_20190126_1535'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'alert'
,
name
=
'urgency_tag'
,
field
=
models
.
CharField
(
choices
=
[(
'info'
,
'Advertising / Announcement'
),
(
'minor'
,
'Expected Hours Change'
),
(
'major'
,
'(Small Scale) Unexpected Hours Change'
),
(
'emergency'
,
'(University Wide) Unexpected Hours Change'
)],
default
=
'Info'
,
max_length
=
10
),
),
migrations
.
AlterField
(
model_name
=
'alert'
,
name
=
'url'
,
field
=
models
.
URLField
(
verbose_name
=
'Reference URL'
),
),
]
whats-open/api/models.py
View file @
80b88a77
...
...
@@ -86,11 +86,7 @@ class Location(TimeStampedModel):
"""
String representation of a Location object.
"""
return
"Found in %s at %s | On Campus: %s"
%
(
self
.
building
,
self
.
address
,
self
.
on_campus
,
)
return
"%s on %s Campus"
%
(
self
.
building
,
self
.
campus_region
.
title
())
class
Facility
(
TimeStampedModel
):
...
...
@@ -413,10 +409,10 @@ class Alert(TimeStampedModel):
# Tuple that ties a urgency tag with a string representation
URGENCY_CHOICES
=
(
(
INFO
,
"
Info
"
),
(
MINOR
,
"
Minor
"
),
(
MAJOR
,
"
Major
"
),
(
EMERGENCY
,
"
Emergency
"
),
(
INFO
,
"
Advertising / Announcement
"
),
(
MINOR
,
"
Expected Hours Change
"
),
(
MAJOR
,
"
(Small Scale) Unexpected Hours Change
"
),
(
EMERGENCY
,
"
(University Wide) Unexpected Hours Change
"
),
)
# The urgency tag for this Alert
...
...
@@ -427,7 +423,7 @@ class Alert(TimeStampedModel):
# The text that is displayed that describes the Alert
subject
=
models
.
CharField
(
max_length
=
130
)
body
=
models
.
TextField
()
url
=
models
.
URLField
(
max_length
=
200
)
url
=
models
.
URLField
(
"Reference URL"
,
max_length
=
200
)
# The date + time that the alert will be start being served
start_datetime
=
models
.
DateTimeField
()
...
...
whats-open/api/views.py
View file @
80b88a77
...
...
@@ -101,7 +101,9 @@ class AlertViewSet(viewsets.ReadOnlyModelViewSet):
FILTER_FIELDS
=
(
# Alert fields
"urgency_tag"
,
"message"
,
"subject"
,
"body"
,
"url"
,
"start_datetime"
,
"end_datetime"
,
)
...
...
whats-open/settings/urls.py
View file @
80b88a77
...
...
@@ -9,9 +9,13 @@ Top level url patterns.
from
django.urls
import
include
,
path
from
django.contrib
import
admin
import
django.contrib.auth.views
from
django.contrib.sites.models
import
Site
from
taggit.admin
import
Tag
# Automatically populate the admin pages
admin
.
autodiscover
()
admin
.
site
.
unregister
(
Site
)
admin
.
site
.
unregister
(
Tag
)
# Define all the top level url patterns in a list
urlpatterns
=
[
...
...
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