Skip to content
Snippets Groups Projects
Commit f0c51135 authored by Jacek Lebioda's avatar Jacek Lebioda
Browse files

Flying team management page

parent e0f64f3b
No related branches found
No related tags found
1 merge request!118Resolve "Flying team location management site"
Pipeline #
......@@ -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),
......
{% 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 %}
......@@ -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>&nbsp;</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>&nbsp;</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">
......
{% 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 %}
<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>
......@@ -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&amp;rooms</span>
<i class="fa fa-building-o"></i> <span>Equipment&amp;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>
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)
......@@ -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 #
......
# 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})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment