diff --git a/golem_activity_queue/models/golem_activity.py b/golem_activity_queue/models/golem_activity.py
index 493e55a..f9bce3b 100644
--- a/golem_activity_queue/models/golem_activity.py
+++ b/golem_activity_queue/models/golem_activity.py
@@ -72,10 +72,19 @@ class GolemActivity(models.Model):
#Ajouter/supprimer une file à l'activité et afficher popup pour traitement automatisé
@api.multi
def queue_allowed_toggle(self):
+ """ Toggle queue_alowed boolean """
for activity in self:
+ #si l'activité contient une file
if activity.queue_allowed:
- activity.queue_allowed = not activity.queue_allowed
+ # si la queue déja contient des elements à supprimer
+ if len(activity.activity_queue_ids) > 0:
+ #parcourir et supprimer les element de la queue
+ for queue in activity.activity_queue_ids:
+ activity.activity_queue_ids = [(2, queue.id, 0)]
+ #changer l'état de queue allowed et automated_registration en false
+ activity.queue_allowed = False
activity.automated_registration_from_queue = False
+
else:
activity.queue_allowed = not activity.queue_allowed
diff --git a/golem_activity_queue/models/golem_activity_queue.py b/golem_activity_queue/models/golem_activity_queue.py
index 507ba58..dc61cae 100644
--- a/golem_activity_queue/models/golem_activity_queue.py
+++ b/golem_activity_queue/models/golem_activity_queue.py
@@ -52,13 +52,14 @@ class GolemActivityQueue(models.Model):
# decider si l'activity liée est pleine ou non : pour group by sur la liste
@api.depends('places_remain')
def _isActivityFull(self):
- print "_____________________________________lklkkaaaa"
+ """ Decide if activity is full or not """
for record in self:
if record.places_remain == 0:
record.is_activity_full = "Full activity"
else:
record.is_activity_full = "Not full activity"
- @api.constrains('member_id')
+
+ @api.constrains('member_id', 'activity_id')
def _check_member_registration(self):
""" Forbid registration in queue when member is already registred in the
activity """
diff --git a/golem_activity_queue/views/golem_activity_views.xml b/golem_activity_queue/views/golem_activity_views.xml
index e1a1998..3ec0847 100644
--- a/golem_activity_queue/views/golem_activity_views.xml
+++ b/golem_activity_queue/views/golem_activity_views.xml
@@ -66,10 +66,12 @@ along with this program. If not, see .
+ attrs="{'invisible': [('queue_allowed', '=', True)]}"
+ confirm="Are you sure you want to do this?"/>
+ attrs="{'invisible': [('queue_allowed', '=', False)]}"
+ confirm="Are you sure you want to remove queue from this activity ? This will delete all elements currently registred in"/>