Mise à jours du code : suppression des blocs inutile et ajout de commentaires

This commit is contained in:
eloyoussef 2018-02-28 13:07:03 +01:00
parent e4596cbda0
commit 5d6c4415cf
6 changed files with 12 additions and 17 deletions

View File

@ -23,7 +23,6 @@ class GolemActivity(models.Model):
""" GOLEM Activity adaptations """
_inherit = 'golem.activity'
#ajout d'un champs O2M vers activity_id de golem.activity.queue
activity_queue_ids = fields.One2many('golem.activity.queue',
'activity_id', 'Pending registration')
@ -34,12 +33,14 @@ class GolemActivity(models.Model):
#ajout d'un champs pour calculer le nombre d'inscription en file d'attente
queue_activity_number = fields.Integer(compute="_compute_queue_activity_number",
store=True, string='Pending registration number')
#changer le mode de basculement en cas de desinctiption
@api.multi
def auto_registration_from_queue_toggle(self):
def auto_registration_toggle(self):
""" switch registration from queueu mode """
for activity in self:
activity.auto_registration_from_queue = not activity.auto_registration_from_queue
#supprimer les personnes en attente si une inscription directement est faite
@api.multi
def write(self, vals):
""" Override method write to delete record from queue if they register in activity"""
@ -110,7 +111,7 @@ class GolemActivity(models.Model):
#depuis attente mode automatique
@api.multi
@api.constrains('activity_registration_ids')
def _automatedRegistrationFromQueue(self):
def _auto_registration_from_queue(self):
"""automated registration from queue"""
for record in self:
# 1 verifier si une place est disponible sur activité

View File

@ -48,7 +48,6 @@ class GolemActivityQueue(models.Model):
('queue_uniq', 'UNIQUE (member_id, activity_id)',
_('This member has already been registered for the queue.'))]
# decider si l'activity liée est pleine ou non : pour group by sur la liste
@api.depends('places_remain')
def _compute_is_activity_full(self):

View File

@ -32,8 +32,10 @@ class GolemMember(models.Model):
if registrations_edited:
for registration_edited in registrations_edited:
if registration_edited[0] == 2:
registration_removed = self.env['golem.activity.registration'].browse(registration_edited[1])
activity_removed = self.env['golem.activity'].browse(registration_removed.activity_id.id)
registration_removed = self.env['golem.activity.registration'].browse(
registration_edited[1])
activity_removed = self.env['golem.activity'].browse(
registration_removed.activity_id.id)
if (activity_removed.queue_allowed and
activity_removed.auto_registration_from_queue and
activity_removed.queue_activity_number > 0):
@ -83,14 +85,8 @@ class GolemMember(models.Model):
#sortir de la boucle parcourissante la queue puisque
# inscription faite
break
elif (activity_removed.queue_allowed and
activity_removed.queue_activity_number > 0):
warning_message = _('There is a free place for the activity'
' : {}, you can fill it from the queue'
' using the button on queue tab')
print warning_message.format(activity_removed.name)
return True
#verifier si nombre d'inscription sur activité est supérieur au place disponible
#inviter l'utilisateur à s'inscrire sur l'attente
@api.multi
@ -114,7 +110,6 @@ class GolemMember(models.Model):
'message': warning_message.format(activity.name),
}
}
#lancer popup pour choisir activité à s'inscrire
@api.multi
def choose_queue_to_register(self):

View File

@ -68,11 +68,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
string="Remove Queue" type="object"
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"/>
<button class="oe_highlight" name="auto_registration_from_queue_toggle"
<button class="oe_highlight" name="auto_registration_toggle"
string="Automated registration from queue" type="object"
attrs="{'invisible': ['|', ('queue_allowed', '=', False),'&amp;', ('queue_allowed', '=', True), ('auto_registration_from_queue', '=', True)]}"
confirm="Are you sure you want to switch to automated registration from queue mode ?"/>
<button class="oe_highlight" name="auto_registration_from_queue_toggle"
<button class="oe_highlight" name="auto_registration_toggle"
string="Manual registration from queue" type="object"
attrs="{'invisible': ['|', ('queue_allowed', '=', False),'&amp;', ('queue_allowed', '=', True), ('auto_registration_from_queue', '=', False)]}"
confirm="Are you sure you want to switch to manual registration from queue mode ?"/>

View File

@ -27,7 +27,6 @@ class GolemActivityAutomatedQueueActivateWizard(models.TransientModel):
activity_id = fields.Many2one("golem.activity")
auto_registration_from_queue = fields.Boolean(default=True)
# lancer liste editable d'inscription sur attente
def activate_queue(self):
""" Activate Queue for the activity"""

View File

@ -27,6 +27,7 @@ class GolemActivityQueueChooseWizard(models.TransientModel):
activity_id = fields.Many2one("golem.activity")
member_id = fields.Many2one("golem.member")
# lancer liste editable d'inscription sur attente
def register_in_queue(self):
""" Choisir l'activité pour s'inscrire sur sa liste d'attente"""