Commit 80b88a77 authored by David Haynes's avatar David Haynes 🙆

Small touchups to the admin

- Making things look nice
parent 133462d1
Pipeline #3758 passed with stage
in 1 minute and 10 seconds
......@@ -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
......@@ -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"
# 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'),
),
]
......@@ -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()
......
......@@ -101,7 +101,9 @@ class AlertViewSet(viewsets.ReadOnlyModelViewSet):
FILTER_FIELDS = (
# Alert fields
"urgency_tag",
"message",
"subject",
"body",
"url",
"start_datetime",
"end_datetime",
)
......
......@@ -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 = [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment