-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create dashboard for application periods
- Loading branch information
Showing
8 changed files
with
333 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from django import forms | ||
from django.core.exceptions import ValidationError | ||
from django.utils import timezone | ||
|
||
from apps.dashboard.widgets import DatetimePickerInput, multiple_widget_generator | ||
|
||
from ..models import CommitteeApplicationPeriod | ||
|
||
|
||
class CommitteeApplicationPeriodForm(forms.ModelForm): | ||
def clean(self): | ||
cleaned_data = super().clean() | ||
data = cleaned_data.copy() | ||
data.pop("committees") | ||
period = CommitteeApplicationPeriod(**data) | ||
|
||
minimum_duration = timezone.timedelta(days=1) | ||
if period.start + minimum_duration >= period.deadline: | ||
raise ValidationError("En opptaksperiode må vare i minst én dag") | ||
|
||
actual_deadline = period.deadline + period.deadline_delta | ||
overlapping_periods = CommitteeApplicationPeriod.objects.filter_overlapping( | ||
period.start, actual_deadline | ||
) | ||
|
||
if overlapping_periods.exists(): | ||
raise ValidationError("Opptaksperioder kan ikke overlappe med hverandre") | ||
|
||
return cleaned_data | ||
|
||
class Meta: | ||
model = CommitteeApplicationPeriod | ||
fields = ("title", "start", "deadline", "deadline_delta", "committees") | ||
|
||
dtp_fields = (("start", {}), ("deadline", {})) | ||
widgetlist = [(DatetimePickerInput, dtp_fields)] | ||
|
||
widgets = multiple_widget_generator(widgetlist) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
templates/approval/dashboard/application_period/create.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{% extends 'dashboard_base.html' %} | ||
{% load render_bundle from webpack_loader %} | ||
{% load crispy_forms_tags %} | ||
|
||
{% block title %}Opptakerperiode - Legg til{% endblock %} | ||
|
||
{% block styles %} | ||
{{ block.super }} | ||
{% endblock %} | ||
|
||
{% block js %} | ||
{{ block.super }} | ||
{% endblock %} | ||
|
||
{% block page-header %} | ||
{% endblock %} | ||
|
||
{% block breadcrumbs %} | ||
<li><a href="/dashboard/approval/application-periods/">Opptaksperioder</a></li> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="row"> | ||
<form method="POST" action=""> | ||
<div class="col-md-12"> | ||
<button type="submit" class="btn btn-success"><i class="fa fa-save"></i> Lagre</button> | ||
</div> | ||
</div> | ||
<br> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">Opptaksperiode</h3> | ||
</div> | ||
<div class="panel-body"> | ||
{% csrf_token %} | ||
{{ form | crispy }} | ||
</form> | ||
</div> | ||
</div> | ||
{% endblock %} |
32 changes: 32 additions & 0 deletions
32
templates/approval/dashboard/application_period/delete.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{% extends 'dashboard_base.html' %} | ||
{% load render_bundle from webpack_loader %} | ||
{% load crispy_forms_tags %} | ||
|
||
{% block title %}Opptakerperiode - Legg til{% endblock %} | ||
|
||
{% block styles %} | ||
{{ block.super }} | ||
{% endblock %} | ||
|
||
{% block js %} | ||
{{ block.super }} | ||
{% endblock %} | ||
|
||
{% block page-header %} | ||
{% endblock %} | ||
|
||
{% block breadcrumbs %} | ||
<li><a href="/dashboard/approval/application-periods/">Opptaksperioder</a></li> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="row"> | ||
<form method="POST" action=""> | ||
<p>Er du helt sikker på at du ønsker å slette "{{ object }}"?</p> | ||
<div class="col-md-12"> | ||
<button type="submit" class="btn btn-danger"><i class="fa fa-times"></i>Slett</button> | ||
</div> | ||
{% csrf_token %} | ||
</form> | ||
</div> | ||
{% endblock %} |
76 changes: 76 additions & 0 deletions
76
templates/approval/dashboard/application_period/detail.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{% extends 'dashboard_base.html' %} | ||
{% load render_bundle from webpack_loader %} | ||
{% load crispy_forms_tags %} | ||
|
||
{% block title %}{{ application_period }}{% endblock %} | ||
|
||
{% block styles %} | ||
{{ block.super }} | ||
{% endblock %} | ||
|
||
{% block js %} | ||
{{ block.super }} | ||
{% endblock %} | ||
|
||
{% block page-header %} | ||
{{ application_period }} | ||
{% endblock %} | ||
|
||
{% block breadcrumbs %} | ||
<li><a href="/dashboard/approval/application-periods/">Opptaksperioder</a></li> | ||
<li>{{ application_period }}</li> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title"> | ||
Søkere | ||
</h3> | ||
</div> | ||
<br /> | ||
<div class="panel-body"> | ||
<p>Dette opptaket har mottat {{ application_period.applications.all | length }} søknader</p> | ||
<a href="{% url 'application-periods-update' pk=application_period.id %}" class="btn btn-warning"><i class="fa fa-cogs"></i> Endre</a> | ||
<a href="{% url 'application-periods-delete' pk=application_period.id %}" class="btn btn-danger pull-right"><i class="fa fa-times"></i> Slett</a> | ||
<br /> | ||
<table class="table table-striped" id="applications"> | ||
<thead> | ||
<tr> | ||
<th>Navn</th> | ||
<th>Søkte grupper</th> | ||
<th>Prioritert rekkefølge</th> | ||
<th>Tidspunkt</th> | ||
</tr> | ||
</thead> | ||
<tbody id="applications-list"> | ||
{% for application in application_period.applications.all %} | ||
<tr> | ||
<td> | ||
{% if application.applicant %} | ||
<a href="{% url 'profiles_view' application.applicant.username %}">{{ application.applicant.get_full_name }}</a> | ||
{% else %} | ||
<p>{{ application.name }} ({{ application.email }})</p> | ||
{% endif %} | ||
</td> | ||
<td> | ||
<p>{{ application.committees.all | join:"; " }} | ||
</td> | ||
<td> | ||
<i class="fa fa-lg {% if application.prioritized %}fa-check-square-o checked{% else %}fa-square-o{% endif %}"></i> | ||
</td> | ||
<td> | ||
{{ application.created | date:"Y-m-j H:i"}} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
47 changes: 47 additions & 0 deletions
47
templates/approval/dashboard/application_period/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{% extends 'dashboard_base.html' %} | ||
{% block title %}Opptaksperioder{% endblock %} | ||
|
||
{% block page-header %} | ||
Grupper | ||
{% endblock %} | ||
|
||
{% block breadcrumbs %} | ||
<li>Grupper</li> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<p></p> | ||
<table class="table table-striped table-condensed"> | ||
<thead> | ||
<tr> | ||
<th>Tittel</th> | ||
<th>Starttid</th> | ||
<th>Frist</th> | ||
<th>Tar imot søknader nå</th> | ||
<th>Antall søknader</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for application_period in application_periods %} | ||
<tr> | ||
<td><a href="{% url 'application-periods-detail' pk=application_period.id %}">{{ application_period }}</a></td> | ||
<td>{{ application_period.start | date:"Y-m-j H:i"}}</td> | ||
<td>{{ application_period.deadline | date:"Y-m-j H:i"}}</td> | ||
<td> | ||
<i class="fa fa-lg {% if application_period.accepting_applications %}fa-check-square-o checked{% else %}fa-square-o{% endif %}"></i> | ||
</td> | ||
<td>{{ application_period.applications.count }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block js %} | ||
{{ block.super }} | ||
<!-- Dashboard JS here --> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters