def save(self, force_insert=False, force_update=False, using=None, update_fields=None, new_num=True): if (self.id is None) and new_num: val = Adherent.objects.all().aggregate(Max('num')) if val['num__max'] is None: self.num = 1 else: self.num = val['num__max'] + 1 Individual.save(self, force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)
def get_show_fields(cls): fields = Individual.get_show_fields() keys = list(fields.keys()) if Params.getvalue("member-numero"): fields[keys[0]][0] = ("num", fields[keys[0]][0]) if Params.getvalue("member-birth"): fields[keys[0]].insert(-1, ("birthday", "birthplace")) fields[keys[0]].insert(-1, ((_("age category"), "age_category"),)) fields[_('002@Subscription')] = ['subscription_set'] fields[''] = [((_("reference date"), "dateref"),)] return fields
def get_edit_fields(cls): fields = Individual.get_edit_fields() if Params.getvalue("member-birth"): fields.insert(-1, ("birthday", "birthplace")) return fields
def get_renew_fields(cls): fields = Individual.get_default_fields() if Params.getvalue("member-numero"): fields.insert(0, "num") return fields
def __init__(self, *args, **kwargs): Individual.__init__(self, *args, **kwargs) self.date_ref = None
def create_individual(firstname, lastname): empty_contact = Individual() empty_contact.firstname = firstname empty_contact.lastname = lastname empty_contact.address = "rue de la liberté" empty_contact.postal_code = "97250" empty_contact.city = "LE PRECHEUR" empty_contact.country = "MARTINIQUE" empty_contact.tel2 = "02-78-45-12-95" empty_contact.email = "*****@*****.**" % (firstname, lastname) empty_contact.save() return empty_contact