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

Rooms management

parent c8630470
No related branches found
No related tags found
1 merge request!123Resolve "Rooms management page"
...@@ -7,7 +7,7 @@ from django.forms import ModelForm, Form ...@@ -7,7 +7,7 @@ from django.forms import ModelForm, Form
from django.utils.dates import MONTHS from django.utils.dates import MONTHS
from web.models import Appointment, AppointmentType, AppointmentTypeLink, \ from web.models import Appointment, AppointmentType, AppointmentTypeLink, \
Availability, ContactAttempt, FlyingTeam, Holiday, StudySubject, \ Availability, ContactAttempt, FlyingTeam, Holiday, StudySubject, Room, \
Worker, Visit, VoucherType, VoucherTypePrice Worker, Visit, VoucherType, VoucherTypePrice
from web.models.constants import SUBJECT_TYPE_CHOICES from web.models.constants import SUBJECT_TYPE_CHOICES
from web.views.notifications import get_filter_locations from web.views.notifications import get_filter_locations
...@@ -400,3 +400,7 @@ class HolidayAddForm(ModelForm): ...@@ -400,3 +400,7 @@ class HolidayAddForm(ModelForm):
validate_availability_conflict(self, self.cleaned_data, availability) validate_availability_conflict(self, self.cleaned_data, availability)
class RoomForm(ModelForm):
class Meta:
model = Room
fields = '__all__'
{% 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 room{% endblock page_header %}
{% block page_description %}{% endblock page_description %}
{% block title %}{{ block.super }} - Add new room{% endblock %}
{% block breadcrumb %}
{% include "equipment_and_rooms/rooms/breadcrumb.html" %}
{% endblock breadcrumb %}
{% block maincontent %}
<div class="box box-info">
<div class="box-header with-border">
<a href="{% url 'web.views.equipment_and_rooms.rooms' %}" 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.rooms' %}" 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.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><a href="{% url 'web.views.equipment_and_rooms' %}">Equipment and rooms</a></li>
<li class="active"><a href="">Rooms</a></li> <li class="active"><a href="{% url 'web.views.equipment_and_rooms.rooms' %}">Rooms</a></li>
{% 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 %}Edit room{% endblock page_header %}
{% block page_description %}{% endblock page_description %}
{% block title %}{{ block.super }} - Edit room{% endblock %}
{% block breadcrumb %}
{% include "equipment_and_rooms/rooms/breadcrumb.html" %}
{% endblock breadcrumb %}
{% block maincontent %}
<div class="box box-info">
<div class="box-header with-border">
<a href="{% url 'web.views.equipment_and_rooms.rooms' %}" 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">Save</button>
</div>
<div class="col-sm-6">
<a href="{% url 'web.views.equipment_and_rooms.rooms' %}" class="btn btn-block btn-default">Cancel</a>
</div>
</div><!-- /.box-footer -->
</form>
</div>
{% endblock %}
{% 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 %}Rooms{% endblock page_header %}
{% block page_description %}management{% endblock page_description %}
{% block breadcrumb %}
{% include "equipment_and_rooms/rooms/breadcrumb.html" %}
{% endblock breadcrumb %}
{% block maincontent %}
<div>
<a href="{% url 'web.views.equipment_and_rooms.rooms_add' %}" class="btn btn-app">
<i class="fa fa-plus"></i>
Add new room</a>
</div>
<div class="box-body">
{% if rooms_list %}
<table id="table" class="table table-bordered table-striped">
<thead>
<tr>
<th>No.</th>
<th>City</th>
<th>Address</th>
<th>Owner</th>
<th>Details</th>
<th>Remove</th>
</tr>
</thead>
<tbody>
{% for room in rooms_list %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ room.city }}</td>
<td>{{ room.address }}</td>
<td>{{ room.owner }}</td>
<td>
<a href="{% url 'web.views.equipment_and_rooms.rooms_edit' room.id %}" type="button"
class="btn btn-block btn-default">Details</a></td>
</td>
<td>
<a href="{% url 'web.views.equipment_and_rooms.rooms_delete' room.id %}" type="button"
class="btn btn-block btn-danger">Remove</a></td>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>No rooms found.</p>
{% endif %}
{% endblock maincontent %}
...@@ -38,8 +38,9 @@ ...@@ -38,8 +38,9 @@
</span> </span>
</a> </a>
<ul class="treeview-menu"> <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> <li><a href="{% url 'web.views.equipment_and_rooms.flying_teams' %}">Flying teams</a></li>
<li><a href="{% url 'web.views.kit_requests' %}">Kit requests</a></li>
<li><a href="{% url 'web.views.equipment_and_rooms.rooms' %}">Rooms</a></li>
</ul> </ul>
</li> </li>
......
...@@ -131,6 +131,10 @@ urlpatterns = [ ...@@ -131,6 +131,10 @@ urlpatterns = [
url(r'^equipment_and_rooms/flying_teams$', views.flying_teams.flying_teams, name='web.views.equipment_and_rooms.flying_teams'), url(r'^equipment_and_rooms/flying_teams$', views.flying_teams.flying_teams, name='web.views.equipment_and_rooms.flying_teams'),
url(r'^equipment_and_rooms/flying_teams/add$', views.flying_teams.flying_teams_add, name='web.views.equipment_and_rooms.flying_teams_add'), url(r'^equipment_and_rooms/flying_teams/add$', views.flying_teams.flying_teams_add, name='web.views.equipment_and_rooms.flying_teams_add'),
url(r'^equipment_and_rooms/flying_teams/edit/(?P<flying_team_id>\d+)$', views.flying_teams.flying_teams_edit, name='web.views.equipment_and_rooms.flying_teams_edit'), url(r'^equipment_and_rooms/flying_teams/edit/(?P<flying_team_id>\d+)$', views.flying_teams.flying_teams_edit, name='web.views.equipment_and_rooms.flying_teams_edit'),
url(r'^equipment_and_rooms/rooms$', views.rooms.rooms, name='web.views.equipment_and_rooms.rooms'),
url(r'^equipment_and_rooms/rooms/add$', views.rooms.rooms_add, name='web.views.equipment_and_rooms.rooms_add'),
url(r'^equipment_and_rooms/rooms/edit/(?P<room_id>\d+)$', views.rooms.rooms_edit, name='web.views.equipment_and_rooms.rooms_edit'),
url(r'^equipment_and_rooms/rooms/delete/(?P<room_id>\d+)$', views.rooms.rooms_delete, name='web.views.equipment_and_rooms.rooms_delete'),
#################### ####################
# MAIL # # MAIL #
......
...@@ -82,4 +82,5 @@ import voucher ...@@ -82,4 +82,5 @@ import voucher
import voucher_type import voucher_type
import voucher_type_price import voucher_type_price
import redcap import redcap
import rooms
import uploaded_files import uploaded_files
# coding=utf-8
from django.shortcuts import redirect, get_object_or_404
from . import wrap_response
from ..models import Room
from ..forms.forms import RoomForm
def rooms(request):
rooms_list = Room.objects.order_by('-city')
context = {
'rooms_list': rooms_list
}
return wrap_response(request,
"equipment_and_rooms/rooms/index.html",
context)
def rooms_add(request):
if request.method == 'POST':
form = RoomForm(request.POST)
if form.is_valid():
form.save()
return redirect('web.views.equipment_and_rooms.rooms')
else:
form = RoomForm()
return wrap_response(request, 'equipment_and_rooms/rooms/add.html', {'form': form})
def rooms_edit(request, room_id):
the_room = get_object_or_404(Room, id=room_id)
if request.method == 'POST':
form = RoomForm(request.POST, instance=the_room)
if form.is_valid():
form.save()
return redirect('web.views.equipment_and_rooms.rooms')
else:
form = RoomForm(instance=the_room)
return wrap_response(request, 'equipment_and_rooms/rooms/edit.html', {'form': form})
def rooms_delete(request, room_id):
the_room = get_object_or_404(Room, id=room_id)
the_room.delete()
return redirect('web.views.equipment_and_rooms.rooms')
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