Skip to content

Commit

Permalink
Merge pull request #761 from WPI-LNL/dev
Browse files Browse the repository at this point in the history
Add dynamic page titles
  • Loading branch information
pfrunzio committed Mar 7, 2023
2 parents 5b42589 + 2950cc5 commit ccde804
Show file tree
Hide file tree
Showing 77 changed files with 116 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ tags
env/
docs/_build/*
.DS_Store
.python-version
7 changes: 5 additions & 2 deletions accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
from .models import Officer, ProfilePhoto, UserPreferences


class UserAddView(mixins.HasPermMixin, generic.CreateView):
class UserAddView(mixins.SetFormMsgMixin, mixins.HasPermMixin, generic.CreateView):
"""Add a new user manually (should rarely be used - LDAP does this for us)"""
form_class = forms.UserAddForm
model = get_user_model()
perms = 'accounts.add_user'
template_name = 'form_crispy.html'
msg = "Add User Manually"

def get_success_url(self):
return reverse('accounts:detail', args=(self.object.id,))
Expand Down Expand Up @@ -367,11 +368,12 @@ def shame(request):
return render(request, 'users_shame.html', context)


class PasswordSetView(generic.FormView):
class PasswordSetView(mixins.SetFormMsgMixin, generic.FormView):
"""Set a non-SSO login password"""
model = get_user_model()
user = None
template_name = 'form_crispy.html'
msg = "Set Non-SSO Login Password"

def form_valid(self, form):
form.save()
Expand Down Expand Up @@ -445,6 +447,7 @@ def user_preferences(request):
def officer_photos(request, pk=None):
"""Update officer headshot (displayed on the main LNL website about page)"""
context = {}
context['msg'] = "Update Officer Photo"
if pk is None:
pk = request.user.pk
officer = get_object_or_404(get_user_model(), pk=pk)
Expand Down
12 changes: 7 additions & 5 deletions devices/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, *args, **kwargs):
self.helper.form_class = "form-horizontal col-md-6"
self.helper.layout = Layout(
Fieldset(
'New Managed Device',
'', #leaving as empty string so page title can be provided by "msg" context variable in the crispy form
Div(
HTML('<p style="font-weight: bold"><span style="color: red">WARNING:</span> Please read the '
'following statements carefully. The MDM is designed for use with LNL equipment only. Failure '
Expand Down Expand Up @@ -1401,7 +1401,8 @@ def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.form_class = "form-horizontal col-md-6"
self.helper.layout = Layout(
Fieldset(title, 'name', 'version', 'developer', 'description', 'developer_website'),
#leaving first arg as empty string so page title can be provided by "msg" context variable in the crispy form:
Fieldset('', 'name', 'version', 'developer', 'description', 'developer_website'),
FormActions(Submit('save', "Submit"))
)
super(NewAppForm, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -1436,7 +1437,7 @@ def __init__(self, *args, **kwargs):
self.helper.form_class = "form-horizontal col-md-6"
self.helper.layout = Layout(
Fieldset(
'Application Info',
'', #leaving as empty string so page title can be provided by "msg" context variable in the crispy form
Div(
'name',
'identifier',
Expand Down Expand Up @@ -1473,11 +1474,12 @@ class AppMergeForm(forms.Form):

def __init__(self, *args, **kwargs):
pk = kwargs.pop('pk')
app_name = MacOSApp.objects.get(pk=pk).name
#app_name = MacOSApp.objects.get(pk=pk).name
self.helper = FormHelper()
self.helper.form_class = "form-horizontal col-md-6"
self.helper.layout = Layout(
Fieldset('Merge ' + app_name + ' into...', 'options'),
#leaving first arg as empty string so page title can be provided by "msg" context variable in the crispy form
Fieldset('', 'options'),
FormActions(Submit('save', 'Merge'))
)
super(AppMergeForm, self).__init__(*args, **kwargs)
Expand Down
6 changes: 6 additions & 0 deletions devices/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def install_client(request):
context['form'] = form
else:
context['form'] = ClientForm()
context['msg'] = "New Managed Device"
return render(request, 'form_crispy.html', context)


Expand Down Expand Up @@ -697,6 +698,7 @@ def generate_profile(request, pk=0):
"if (this.value == 'default') {$('#div_id_removal_date').hide();" \
"$('#div_id_removal_period').hide();}else{$('#div_id_removal_date').show();" \
"$('#div_id_removal_period').show();}});$('#id_auto_remove').change();});"
context['msg'] = "Manage Configuration Profile"
return render(request, 'form_crispy.html', context)


Expand Down Expand Up @@ -917,6 +919,7 @@ def add_app(request):
else:
form = NewAppForm(title=title, request_user=request.user)
context['form'] = form
context['msg'] = title
return render(request, 'form_crispy.html', context)


Expand Down Expand Up @@ -970,6 +973,7 @@ def update_app_info(request, pk):
else:
form = UpdateAppForm(instance=app)
context['form'] = form
context['msg'] = "Application Info"
return render(request, 'form_crispy.html', context)


Expand Down Expand Up @@ -1007,6 +1011,8 @@ def merge_app(request, pk):
else:
form = AppMergeForm(pk=pk)
context['form'] = form
app_name = MacOSApp.objects.get(pk=pk).name
context['msg'] = 'Merge ' + app_name + ' into...'
return render(request, 'form_crispy.html', context)


Expand Down
8 changes: 4 additions & 4 deletions events/views/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ class CCRDelete(SetFormMsgMixin, HasPermOrTestMixin, LoginRequiredMixin, DeleteV
""" Delete a crew chief report """
model = CCReport
template_name = "form_delete_cbv.html"
msg = "Deleted Crew Chief Report"
msg = "Delete Crew Chief Report"
perms = 'events.delete_ccreport'

def user_passes_test(self, request, *args, **kwargs):
Expand Down Expand Up @@ -1244,10 +1244,10 @@ def get_success_url(self):
return reverse("events:detail", args=(self.kwargs['event'],)) + "#billing"


class BillingDelete(HasPermMixin, LoginRequiredMixin, DeleteView):
class BillingDelete(SetFormMsgMixin, HasPermMixin, LoginRequiredMixin, DeleteView):
model = Billing
template_name = "form_delete_cbv.html"
msg = "Deleted Bill"
msg = "Delete Bill"
perms = 'events.bill_event'

def dispatch(self, request, *args, **kwargs):
Expand Down Expand Up @@ -1317,7 +1317,7 @@ def get_success_url(self):
return reverse("events:multibillings:list")


class MultiBillingDelete(HasPermMixin, LoginRequiredMixin, DeleteView):
class MultiBillingDelete(SetFormMsgMixin, HasPermMixin, LoginRequiredMixin, DeleteView):
model = MultiBilling
template_name = "form_delete_cbv.html"
msg = "Delete MultiBill"
Expand Down
5 changes: 3 additions & 2 deletions events/views/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.utils.http import urlencode
from django.utils.timezone import make_aware

from helpers.mixins import HasPermMixin, LoginRequiredMixin
from helpers.mixins import HasPermMixin, LoginRequiredMixin, SetFormMsgMixin
from events.models import BaseEvent, Event2019, Category, MultiBilling, Workshop, WorkshopDate
from events.forms import WorkshopForm, WorkshopDatesForm

Expand Down Expand Up @@ -963,6 +963,7 @@ def workshop_dates(request, pk):
formset.save()
return HttpResponseRedirect(reverse("events:workshops:list"))
context['formset'] = formset
context['msg'] = "Workshop Dates for \"" + workshop.name + "\""
return render(request, 'formset_workshop_dates.html', context)


Expand All @@ -974,7 +975,7 @@ def workshops_list(request):
return render(request, 'workshops_list.html', {'workshops': workshops})


class DeleteWorkshop(LoginRequiredMixin, HasPermMixin, DeleteView):
class DeleteWorkshop(SetFormMsgMixin, LoginRequiredMixin, HasPermMixin, DeleteView):
""" Delete a series of workshops """
model = Workshop
template_name = "form_delete_cbv.html"
Expand Down
4 changes: 2 additions & 2 deletions meetings/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from email.encoders import encode_base64
from helpers.util import curry_class

from helpers.mixins import HasPermMixin, LoginRequiredMixin
from helpers.mixins import HasPermMixin, LoginRequiredMixin, SetFormMsgMixin
from data.views import serve_file
from emails.generators import generate_notice_cc_email, generate_notice_email, DefaultLNLEmailGenerator
from events.forms import CCIForm
Expand Down Expand Up @@ -240,7 +240,7 @@ def newattendance(request):
return render(request, 'form_crispy_meetings.html', context)


class DeleteMeeting(LoginRequiredMixin, HasPermMixin, DeleteView):
class DeleteMeeting(SetFormMsgMixin, LoginRequiredMixin, HasPermMixin, DeleteView):
""" Delete a meeting """
model = Meeting
template_name = "form_delete_cbv.html"
Expand Down
3 changes: 1 addition & 2 deletions members/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.help_text_inline = True
self.helper.layout = Layout(
HTML('<h1>Record a Training</h1>'),
'training_type',
'date',
'trainer',
Expand Down Expand Up @@ -69,7 +68,7 @@ def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.help_text_inline = True
self.helper.layout = Layout(
HTML('<h2>Edit notes on {} for {}</h2>'.format(self.instance.person, self.instance.training)),
HTML('<h4>Edit notes on {} for {}</h4>'.format(self.instance.person, self.instance.training)),
'notes',
FormActions(
Submit('save', 'Save'),
Expand Down
4 changes: 2 additions & 2 deletions members/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def enter_training(request):
return HttpResponseRedirect(reverse('members:training:list'))
else:
form = TrainingForm()
return render(request, 'form_crispy.html', {'form': form})
return render(request, 'form_crispy.html', {'form': form, 'msg': "Record a Training"})


@login_required
Expand All @@ -84,7 +84,7 @@ def trainee_notes(request, pk):
return HttpResponseRedirect(reverse('accounts:detail', args=(trainee.person.pk,)))
else:
form = TraineeNotesForm(instance=trainee)
return render(request, 'form_crispy.html', {'form': form})
return render(request, 'form_crispy.html', {'form': form, 'msg':"Edit Training Notes"})


@login_required
Expand Down
12 changes: 7 additions & 5 deletions projection/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.views.generic.edit import CreateView, DeleteView, FormView
from django.urls.base import reverse

from helpers.mixins import HasPermMixin, LoginRequiredMixin
from helpers.mixins import HasPermMixin, LoginRequiredMixin, SetFormMsgMixin
from projection.forms import (BulkCreateForm, BulkUpdateForm, DateEntryFormSetBase, ProjectionistForm,
ProjectionistUpdateForm, PITRequestForm, PITRequestAdminForm, PITFormset)
from projection.models import PITLevel, Projectionist, PitRequest, PitInstance
Expand Down Expand Up @@ -83,7 +83,7 @@ def projection_update(request, id):
return render(request, 'form_crispy_projection.html', context)


class ProjectionCreate(LoginRequiredMixin, HasPermMixin, CreateView):
class ProjectionCreate(SetFormMsgMixin, LoginRequiredMixin, HasPermMixin, CreateView):
""" Add a new projectionist """
perms = 'projection.edit_pits'

Expand Down Expand Up @@ -116,6 +116,7 @@ def get_context_data(self, **kwargs):

model = Projectionist
template_name = "form_crispy_projection.html"
msg = "Add Projectionist"
form_class = ProjectionistForm
# success_url = reverse("projection:list")

Expand All @@ -124,9 +125,10 @@ def success_url(self):
return reverse("projection:grid")


class BulkUpdateView(LoginRequiredMixin, HasPermMixin, FormView):
class BulkUpdateView(SetFormMsgMixin, LoginRequiredMixin, HasPermMixin, FormView):
""" Update a PIT for multiple projectionists at the same time """
template_name = "form_crispy_cbv.html"
msg = "Bulk Update Projectionists"
form_class = BulkUpdateForm
perms = 'projection.edit_pits'

Expand All @@ -141,11 +143,11 @@ def form_valid(self, form):
return super(BulkUpdateView, self).form_valid(form)


class ProjectionistDelete(LoginRequiredMixin, HasPermMixin, DeleteView):
class ProjectionistDelete(SetFormMsgMixin, LoginRequiredMixin, HasPermMixin, DeleteView):
""" Remove a projectionist (does not remove the associated user) """
model = Projectionist
template_name = "form_delete_cbv.html"
msg = "Deleted Projectionist"
msg = "Delete Projectionist"
perms = 'projection.edit_pits'

def get_success_url(self):
Expand Down
1 change: 1 addition & 0 deletions site_tmpl/access_log.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends 'base_admin.html' %}
{% block title %}{{title}} | Lens and Lights at WPI{% endblock %}
{% block content %}
<h1>{{ title }}</h1>
<br>
Expand Down
1 change: 1 addition & 0 deletions site_tmpl/admin.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends 'base_admin.html' %}
{% load tz %}
{% load permissionif %}
{% block title %}Database Home | Lens and Lights at WPI{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-12">
Expand Down
1 change: 1 addition & 0 deletions site_tmpl/default.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends 'base_admin.html' %}

{% block title %}{{title}} | Lens and Lights at WPI{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-8">
Expand Down
2 changes: 2 additions & 0 deletions site_tmpl/email_tools.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{% extends 'base_admin.html' %}
{% load permissionif %}

{% block title %}Communication Tools | Lens and Lights at WPI{% endblock %}

{% block extras %}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
{% endblock %}
Expand Down
1 change: 1 addition & 0 deletions site_tmpl/event_review.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% load markdown_deux_tags %}
{% load crispy_forms_tags %}

{% block title %}{{ h2 }}: {{ event.event_name }} | Lens and Lights at WPI{% endblock %}

{% block content %}
<h1>{{ h2 }}</h1>
Expand Down
1 change: 1 addition & 0 deletions site_tmpl/events.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{% block extras %}
{% include 'js_event_checkboxes.tmpl' %}
{% endblock %}
{% block title %}{{h2}} | Lens and Lights at WPI{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-12">
Expand Down
2 changes: 2 additions & 0 deletions site_tmpl/events_cal.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
{% bootstrap_calendar_css %}
{% endblock %}

{% block title %}{{ h2 }} Calendar | Lens and Lights at WPI{% endblock %}

{% block content %}
<div class="row">
<div class="col-md-12">
Expand Down
2 changes: 2 additions & 0 deletions site_tmpl/events_public.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{% extends 'base_admin.html' %}
{% load bootstrap_calendar %}

{% block title %}Ongoing and Future Events | Lens and Lights at WPI{% endblock %}

{% block extras %}
{% url 'cal:api-public' as bootcal_endpoint %}
{% bootstrap_calendar_js events_url=bootcal_endpoint %}
Expand Down
1 change: 1 addition & 0 deletions site_tmpl/events_search_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% block extras %}
{% include 'js_event_checkboxes.tmpl' %}
{% endblock %}
{% block title %}Event Search: {{q}} | Lens and Lights at WPI{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-12">
Expand Down
1 change: 1 addition & 0 deletions site_tmpl/form_cancel_request.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends 'base_admin.html' %}

{% block title %}Cancel PIT Request | Lens and Lights at WPI{% endblock %}
{% block content %}
<h3>Are you sure you want to cancel this request?</h3>
<form action="" method="post">{% csrf_token %}
Expand Down
2 changes: 2 additions & 0 deletions site_tmpl/form_crispy.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{% extends 'base_admin.html' %}
{% load crispy_forms_tags %}

{% block title %}{{msg}} | Lens and Lights at WPI{% endblock %}

{% block content %}
<div class="row">
<div class="col-md-12">
Expand Down
1 change: 1 addition & 0 deletions site_tmpl/form_crispy_approval.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends 'base_admin.html' %}
{% load crispy_forms_tags %}

{% block title %}{{msg}} | Lens and Lights at WPI{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-12">
Expand Down
2 changes: 2 additions & 0 deletions site_tmpl/form_crispy_bulk_projection_done.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends 'base_admin.html' %}

{% block title %}Added Bulk Movies | Lens and Lights at WPI{% endblock %}

{% block content %}
<div class="row">
<div class="col-md-12">
Expand Down

0 comments on commit ccde804

Please sign in to comment.