mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 19:33:11 +00:00
Merge branch 'create_machine_users' into 'master'
Création d'un réglage permettant de modifier le droit de créer une machine See merge request federez/re2o!82
This commit is contained in:
commit
d8005624f5
5 changed files with 34 additions and 0 deletions
|
@ -96,6 +96,8 @@ class Machine(FieldPermissionModelMixin, models.Model):
|
|||
return False, u"Utilisateur inexistant"
|
||||
max_lambdauser_interfaces = preferences.models.OptionalMachine.get_cached_value('max_lambdauser_interfaces')
|
||||
if not user_request.has_perm('machines.add_machine'):
|
||||
if not preferences.models.OptionalMachine.get_cached_value('create_machine'):
|
||||
return False, u"Vous ne pouvez pas ajouter une machine"
|
||||
if user != user_request:
|
||||
return False, u"Vous ne pouvez pas ajouter une machine à un\
|
||||
autre user que vous sans droit"
|
||||
|
@ -1335,6 +1337,8 @@ class Interface(FieldPermissionModelMixin,models.Model):
|
|||
except Machine.DoesNotExist:
|
||||
return False, u"Machine inexistante"
|
||||
if not user_request.has_perm('machines.add_interface'):
|
||||
if not preferences.models.OptionalMachine.get_cached_value('create_machine'):
|
||||
return False, u"Vous ne pouvez pas ajouter une machine"
|
||||
max_lambdauser_interfaces = preferences.models.OptionalMachine.get_cached_value('max_lambdauser_interfaces')
|
||||
if machine.user != user_request:
|
||||
return False, u"Vous ne pouvez pas ajouter une interface à une\
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2018-02-28 13:40
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('preferences', '0042_auto_20180222_1743'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='optionalmachine',
|
||||
name='create_machine',
|
||||
field=models.BooleanField(default=True, help_text="Permet à l'user de créer une machine"),
|
||||
),
|
||||
]
|
|
@ -185,6 +185,10 @@ class OptionalMachine(PreferencesModel):
|
|||
choices=CHOICE_IPV6,
|
||||
default='DISABLED'
|
||||
)
|
||||
create_machine = models.BooleanField(
|
||||
default=True,
|
||||
help_text="Permet à l'user de créer une machine"
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def ipv6(self):
|
||||
|
|
|
@ -90,6 +90,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<th>Support de l'ipv6</th>
|
||||
<td>{{ machineoptions.ipv6_mode }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Creation de machines</th>
|
||||
<td>{{ machineoptions.create_machine }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h4>Préférences topologie</h4>
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:edit-options' 'OptionalTopologie' %}">
|
||||
|
|
|
@ -189,7 +189,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
</table>
|
||||
{% endif %}
|
||||
<h2>Machines</h2>
|
||||
{% can_create Machine users.id %}
|
||||
<h4><a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-machine' users.id %}"><i class="glyphicon glyphicon-phone"></i> Ajouter une machine</a></h4>
|
||||
{% acl_end %}
|
||||
{% if machines_list %}
|
||||
{% include "machines/aff_machines.html" with machines_list=machines_list %}
|
||||
{% else %}
|
||||
|
|
Loading…
Reference in a new issue