mirror of https://gitlab.federez.net/re2o/re2o
10 changed files with 313 additions and 6 deletions
@ -0,0 +1,47 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.10.7 on 2019-02-18 16:43 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
import re2o.mixins |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('topologie', '0069_auto_20190108_1439'), |
||||
|
] |
||||
|
|
||||
|
def create_dormitory(apps, schema_editor): |
||||
|
db_alias = schema_editor.connection.alias |
||||
|
dormitory = apps.get_model("topologie", "Dormitory") |
||||
|
building = apps.get_model("topologie", "Building") |
||||
|
dorm = dormitory.objects.using(db_alias).create(name="Residence") |
||||
|
building.objects.using(db_alias).update(dormitory=dorm) |
||||
|
|
||||
|
def delete_dormitory(apps, schema_editor): |
||||
|
pass |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.CreateModel( |
||||
|
name='Dormitory', |
||||
|
fields=[ |
||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
|
('name', models.CharField(max_length=255)), |
||||
|
], |
||||
|
options={ |
||||
|
'verbose_name': 'dormitory', |
||||
|
'permissions': (('view_dormitory', 'Can view a dormitory object'),), |
||||
|
'verbose_name_plural': 'dormitories', |
||||
|
}, |
||||
|
bases=(re2o.mixins.AclMixin, re2o.mixins.RevMixin, models.Model), |
||||
|
), |
||||
|
migrations.AddField( |
||||
|
model_name='building', |
||||
|
name='dormitory', |
||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='topologie.Dormitory'), |
||||
|
preserve_default=False, |
||||
|
), |
||||
|
migrations.RunPython(create_dormitory, delete_dormitory) |
||||
|
] |
||||
@ -0,0 +1,56 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.10.7 on 2019-02-18 18:36 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('topologie', '0070_auto_20190218_1743'), |
||||
|
] |
||||
|
|
||||
|
def transfer_room(apps, schema_editor): |
||||
|
db_alias = schema_editor.connection.alias |
||||
|
room_obj = apps.get_model("topologie", "Room") |
||||
|
building_obj = apps.get_model("topologie", "Building") |
||||
|
dorm_obj = apps.get_model("topologie", "Dormitory") |
||||
|
dorm = dorm_obj.objects.using(db_alias).first() |
||||
|
for room in room_obj.objects.using(db_alias).all(): |
||||
|
building, created = building_obj.objects.using(db_alias).get_or_create(name=room.name[0].upper(), dormitory=dorm) |
||||
|
room.building = building |
||||
|
room.name = room.name[1:] |
||||
|
room.save() |
||||
|
|
||||
|
def untransfer_room(apps, schema_editor): |
||||
|
pass |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AlterField( |
||||
|
model_name='room', |
||||
|
name='name', |
||||
|
field=models.CharField(max_length=255), |
||||
|
), |
||||
|
migrations.AddField( |
||||
|
model_name='room', |
||||
|
name='building', |
||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='topologie.Building'), |
||||
|
), |
||||
|
migrations.AlterUniqueTogether( |
||||
|
name='room', |
||||
|
unique_together=set([('name', 'building')]), |
||||
|
), |
||||
|
migrations.AlterField( |
||||
|
model_name='building', |
||||
|
name='dormitory', |
||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='topologie.Dormitory'), |
||||
|
), |
||||
|
migrations.RunPython(transfer_room, untransfer_room), |
||||
|
migrations.AlterField( |
||||
|
model_name='room', |
||||
|
name='building', |
||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='topologie.Building'), |
||||
|
) |
||||
|
] |
||||
@ -0,0 +1,62 @@ |
|||||
|
{% comment %} |
||||
|
Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
||||
|
se veut agnostique au réseau considéré, de manière à être installable en |
||||
|
quelques clics. |
||||
|
|
||||
|
Copyright © 2017 Gabriel Détraz |
||||
|
Copyright © 2017 Goulven Kermarec |
||||
|
Copyright © 2017 Augustin Lemesle |
||||
|
|
||||
|
This program is free software; you can redistribute it and/or modify |
||||
|
it under the terms of the GNU General Public License as published by |
||||
|
the Free Software Foundation; either version 2 of the License, or |
||||
|
(at your option) any later version. |
||||
|
|
||||
|
This program is distributed in the hope that it will be useful, |
||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
GNU General Public License for more details. |
||||
|
|
||||
|
You should have received a copy of the GNU General Public License along |
||||
|
with this program; if not, write to the Free Software Foundation, Inc., |
||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
|
{% endcomment %} |
||||
|
|
||||
|
{% load acl %} |
||||
|
{% load logs_extra %} |
||||
|
{% load i18n %} |
||||
|
|
||||
|
{% if dormitory_list.paginator %} |
||||
|
{% include 'pagination.html' with list=dormitory_list %} |
||||
|
{% endif %} |
||||
|
|
||||
|
<table class="table table-striped"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
{% trans "Dormitory" as tr_dormitory %} |
||||
|
<th>{% include 'buttons/sort.html' with prefix='dormitory' col='name' text=tr_dormitory %}</th> |
||||
|
<th>{% trans "Building" %}</th> |
||||
|
<th></th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
{% for dormitory in dormitory_list %} |
||||
|
<tr> |
||||
|
<td>{{ dormitory.name }}</td> |
||||
|
<td>{% for building in dormitory.building_set.all %} {{ building }} {% endfor %}</td> |
||||
|
<td class="text-right"> |
||||
|
{% can_edit dormitory %} |
||||
|
{% include 'buttons/edit.html' with href='topologie:edit-dormitory' id=dormitory.id %} |
||||
|
{% acl_end %} |
||||
|
{% history_button dormitory %} |
||||
|
{% can_delete dormitory %} |
||||
|
{% include 'buttons/suppr.html' with href='topologie:del-dormitory' id=dormitory.id %} |
||||
|
{% acl_end %} |
||||
|
</td> |
||||
|
</tr> |
||||
|
{% endfor %} |
||||
|
</table> |
||||
|
|
||||
|
{% if dormitory_list.paginator %} |
||||
|
{% include 'pagination.html' with list=dormitory_list %} |
||||
|
{% endif %} |
||||
|
|
||||
Loading…
Reference in new issue