diff --git a/smash/web/forms/forms.py b/smash/web/forms/forms.py index 570db43352dd9935a0ec0f9dc7871d6aaae6c427..f18aed03d562e672fdb35b14702db6f9b33b0fd7 100644 --- a/smash/web/forms/forms.py +++ b/smash/web/forms/forms.py @@ -6,8 +6,9 @@ from django import forms from django.forms import ModelForm, Form from django.utils.dates import MONTHS -from web.models import StudySubject, Worker, Appointment, Visit, AppointmentType, ContactAttempt, AppointmentTypeLink, \ - Availability, Holiday, VoucherType, VoucherTypePrice +from web.models import Appointment, AppointmentType, AppointmentTypeLink, \ + Availability, ContactAttempt, FlyingTeam, Holiday, StudySubject, \ + Worker, Visit, VoucherType, VoucherTypePrice from web.models.constants import SUBJECT_TYPE_CHOICES from web.views.notifications import get_filter_locations @@ -368,6 +369,12 @@ def validate_availability_conflict(self, cleaned_data, availability): self.add_error('available_till', error) +class FlyingTeamAddForm(ModelForm): + class Meta: + model = FlyingTeam + fields = "__all__" + + class HolidayAddForm(ModelForm): datetime_start = forms.DateTimeField(widget=forms.DateTimeInput(DATETIMEPICKER_DATE_ATTRS), initial=datetime.datetime.now().replace(hour=8, minute=0), diff --git a/smash/web/templates/equipment_and_rooms/flying_teams.html b/smash/web/templates/equipment_and_rooms/flying_teams.html new file mode 100644 index 0000000000000000000000000000000000000000..341ec1ffa75b453a083a325bb162adaa11fa3937 --- /dev/null +++ b/smash/web/templates/equipment_and_rooms/flying_teams.html @@ -0,0 +1,47 @@ +{% extends "_base.html" %} +{% load static %} + +{% block styles %} + {{ block.super }} + <!-- DataTables --> + <link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}"> +{% endblock styles %} + +{% block ui_active_tab %}'equipment_and_rooms'{% endblock ui_active_tab %} +{% block page_header %}Flying teams{% endblock page_header %} +{% block page_description %}management{% endblock page_description %} + +{% block breadcrumb %} + {% include "equipment_and_rooms/breadcrumb.html" %} +{% endblock breadcrumb %} + +{% block maincontent %} +<div> + <a href="{% url 'web.views.equipment_and_rooms.flying_teams_add' %}" class="btn btn-app"> + <i class="fa fa-plus"></i> + Add new flying team</a> +</div> + +<div class="box-body"> + {% if flying_team_list %} + <table id="table" class="table table-bordered table-striped"> + <thead> + <tr> + <th>No.</th> + <th>Location</th> + </tr> + </thead> + <tbody> + {% for flying_team in flying_team_list %} + <tr> + <td>{{ forloop.counter }}</td> + <td>{{ flying_team.place }}</td> + </tr> + {% endfor %} + + </tbody> + </table> + {% else %} + <p>No flying teams found.</p> + {% endif %} +{% endblock maincontent %} diff --git a/smash/web/templates/equipment_and_rooms/index.html b/smash/web/templates/equipment_and_rooms/index.html index d9ba8764cd81623bdf3a057e8d9ce708ca61dabc..d4e27c7147abcb32c52818c5358bd6d49d36ab36 100644 --- a/smash/web/templates/equipment_and_rooms/index.html +++ b/smash/web/templates/equipment_and_rooms/index.html @@ -61,20 +61,6 @@ Edit <i class="fa fa-arrow-circle-right"></i> </a> </div> - - <div class="bg-red disabled small-box"> - <div class="inner"> - <h4>Flying teams</h4> - - <p> </p> - </div> - <div class="icon"> - <i class="ion ion-android-car"></i> - </div> - <a href="#" class="small-box-footer"> - Edit <i class="fa fa-arrow-circle-right"></i> - </a> - </div> </div> {% endcomment %} @@ -93,6 +79,20 @@ </a> </div> + <div class="bg-red small-box"> + <div class="inner"> + <h4>Flying teams</h4> + + <p> </p> + </div> + <div class="icon"> + <i class="ion ion-android-car"></i> + </div> + <a href="{% url 'web.views.equipment_and_rooms.flying_teams' %}" class="small-box-footer"> + Manage <i class="fa fa-arrow-circle-right"></i> + </a> + </div> + {% comment %} <div class="bg-yellow small-box"> <div class="inner"> diff --git a/smash/web/templates/flying_teams/add.html b/smash/web/templates/flying_teams/add.html new file mode 100644 index 0000000000000000000000000000000000000000..8b348d775c6deb10c182cb3bba9b47a106fb8c03 --- /dev/null +++ b/smash/web/templates/flying_teams/add.html @@ -0,0 +1,62 @@ +{% extends "_base.html" %} +{% load static %} +{% load filters %} + +{% block styles %} + {{ block.super }} + <link rel="stylesheet" href="{% static 'AdminLTE/plugins/awesomplete/awesomplete.css' %}"/> +{% endblock styles %} + +{% block ui_active_tab %}'equipment_and_rooms'{% endblock ui_active_tab %} +{% block page_header %}New flying team{% endblock page_header %} +{% block page_description %}{% endblock page_description %} + +{% block title %}{{ block.super }} - Add new flying team{% endblock %} + +{% block breadcrumb %} + {% include "flying_teams/breadcrumb.html" %} +{% endblock breadcrumb %} + +{% block maincontent %} + + <div class="box box-info"> + <div class="box-header with-border"> + <a href="{% url 'web.views.doctors' %}" class="btn btn-block btn-default">Go back (without changes)</a> + </div> + + <form method="post" action="" class="form-horizontal"> + {% csrf_token %} + + <div class="box-body"> + <div class="col-sm-6"> + {% for field in form %} + <div class="form-group {% if field.errors %}has-error{% endif %}"> + <label for="{# TODO #}" class="col-sm-4 control-label"> + {{ field.label }} + </label> + + <div class="col-sm-8"> + {{ field|add_class:'form-control' }} + </div> + + {% if field.errors %} + <span class="help-block"> + {{ field.errors }} + </span> + {% endif %} + </div> + {% endfor %} + </div> + </div><!-- /.box-body --> + + <div class="box-footer"> + <div class="col-sm-6"> + <button type="submit" class="btn btn-block btn-success">Add</button> + </div> + <div class="col-sm-6"> + <a href="{% url 'web.views.equipment_and_rooms.flying_teams' %}" class="btn btn-block btn-default">Cancel</a> + </div> + </div><!-- /.box-footer --> + </form> + </div> + {% endblock %} diff --git a/smash/web/templates/flying_teams/breadcrumb.html b/smash/web/templates/flying_teams/breadcrumb.html new file mode 100644 index 0000000000000000000000000000000000000000..1259da09b4464c8cc63a417b77d527b05c3505f5 --- /dev/null +++ b/smash/web/templates/flying_teams/breadcrumb.html @@ -0,0 +1,3 @@ +<li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> +<li><a href="{% url 'web.views.equipment_and_rooms' %}">Equipment and rooms</a></li> +<li class="active"><a href="{% url 'web.views.equipment_and_rooms.flying_teams' %}">Flying teams</a></li> diff --git a/smash/web/templates/sidebar.html b/smash/web/templates/sidebar.html index a8dd1d750c13fb5c824c11c40f9d9681bf535126..70f1ff705b17df0f826c47b921d33f2ed6741c24 100644 --- a/smash/web/templates/sidebar.html +++ b/smash/web/templates/sidebar.html @@ -30,11 +30,17 @@ </a> </li> - <li data-desc="equipment_and_rooms"> + <li data-desc="equipment_and_rooms" class="treeview"> <a href="{% url 'web.views.equipment_and_rooms' %}"> - <i class="fa fa-building-o"></i> - <span>Equipment&rooms</span> + <i class="fa fa-building-o"></i> <span>Equipment&rooms</span> + <span class="pull-right-container"> + <i class="fa fa-angle-left pull-right"></i> + </span> </a> + <ul class="treeview-menu"> + <li><a href="{% url 'web.views.kit_requests' %}">Kit requests</a></li> + <li><a href="{% url 'web.views.equipment_and_rooms.flying_teams' %}">Flying teams</a></li> + </ul> </li> <li data-desc="statistics"> @@ -71,4 +77,4 @@ </ul> </li> -</ul> \ No newline at end of file +</ul> diff --git a/smash/web/tests/view/test_flying_teams.py b/smash/web/tests/view/test_flying_teams.py new file mode 100644 index 0000000000000000000000000000000000000000..52a27ac3258e22f36d0942f5f3a8eacb7ce0ecf5 --- /dev/null +++ b/smash/web/tests/view/test_flying_teams.py @@ -0,0 +1,16 @@ +from django.urls import reverse + +from web.models import FlyingTeam +from web.tests import LoggedInTestCase + + +class FlyingTeamTests(LoggedInTestCase): + def test_flyingteam_requests(self): + pages = [ + 'web.views.equipment_and_rooms.flying_teams', + 'web.views.equipment_and_rooms.flying_teams.add', + ] + + for page in pages: + response = self.client.get(reverse(page)) + self.assertEqual(response.status_code, 200) diff --git a/smash/web/urls.py b/smash/web/urls.py index c2bc3d3bd480fecf6f3977d6c3ed209af04cdb34..24cc549cca0745e454c742f839f5a6b1bf5dfdd1 100644 --- a/smash/web/urls.py +++ b/smash/web/urls.py @@ -128,6 +128,8 @@ urlpatterns = [ name='web.views.kit_requests_send_mail'), url(r'^equipment_and_rooms/kit_requests/(?P<start_date>[\w-]+)/(?P<end_date>[\w-]+)/$', views.kit.kit_requests_send_mail, name='web.views.kit_requests_send_mail'), + url(r'^equipment_and_rooms/flying_teams$', views.equipment.flying_teams, name='web.views.equipment_and_rooms.flying_teams'), + url(r'^equipment_and_rooms/flying_teams/add$', views.equipment.flying_teams_add, name='web.views.equipment_and_rooms.flying_teams_add'), #################### # MAIL # diff --git a/smash/web/views/equipment.py b/smash/web/views/equipment.py index 0a8299071a793695c39d007a65dfe22043b496d2..d145840c7098d7baa93d23aa4d84e839be2ef6c5 100644 --- a/smash/web/views/equipment.py +++ b/smash/web/views/equipment.py @@ -1,6 +1,9 @@ # coding=utf-8 +from django.shortcuts import redirect + from . import wrap_response -from ..models import Item +from ..models import FlyingTeam +from ..forms.forms import FlyingTeamAddForm def equipment_def(request): @@ -14,3 +17,26 @@ def equipment_def(request): def equipment_and_rooms(request): return wrap_response(request, "equipment_and_rooms/index.html", {}) + + +def flying_teams(request): + flying_team_list = FlyingTeam.objects.order_by('-place') + context = { + 'flying_team_list': flying_team_list + } + + return wrap_response(request, + "equipment_and_rooms/flying_teams.html", + context) + + +def flying_teams_add(request): + if request.method == 'POST': + form = FlyingTeamAddForm(request.POST) + if form.is_valid(): + form.save() + return redirect('web.views.equipment_and_rooms.flying_teams') + else: + form = FlyingTeamAddForm() + + return wrap_response(request, 'flying_teams/add.html', {'form': form})