mirror of https://gitlab.crans.org/bde/nk20
Fix registration permissions and procedure
This commit is contained in:
parent
73ca65aa91
commit
180cd3e1ec
|
@ -477,7 +477,12 @@ class Membership(models.Model):
|
|||
# to treasurers.
|
||||
transaction.valid = False
|
||||
from treasury.models import SogeCredit
|
||||
soge_credit = SogeCredit.objects.get_or_create(user=self.user)[0]
|
||||
if SogeCredit.objects.filter(user=self.user).exists():
|
||||
soge_credit = SogeCredit.objects.get(user=self.user)
|
||||
else:
|
||||
soge_credit = SogeCredit(user=self.user)
|
||||
soge_credit._force_save = True
|
||||
soge_credit.save(force_insert=True)
|
||||
soge_credit.refresh_from_db()
|
||||
transaction.save(force_insert=True)
|
||||
transaction.refresh_from_db()
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<dt class="col-xl-6">{% trans 'address'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ user_object.profile.address }}</dd>
|
||||
|
||||
{% if "note.view_note"|has_perm:user_object.note %}
|
||||
{% if user_object.note and "note.view_note"|has_perm:user_object.note %}
|
||||
<dt class="col-xl-6">{% trans 'balance'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ user_object.note.balance | pretty_money }}</dd>
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
|||
{% endif %}
|
||||
</dl>
|
||||
|
||||
{% if user_object.pk == user_object.pk %}
|
||||
{% if user_object.pk == user.pk %}
|
||||
<div class="text-center">
|
||||
<a class="small badge badge-secondary" href="{% url 'member:auth_token' %}">
|
||||
<i class="fa fa-cogs"></i>{% trans 'API token' %}
|
||||
|
|
|
@ -109,12 +109,16 @@ class Note(PolymorphicModel):
|
|||
|
||||
# Save alias
|
||||
a.note = self
|
||||
# Consider that if the name of the note could be changed, then the alias can be created.
|
||||
# It does not mean that any alias can be created.
|
||||
a._force_save = True
|
||||
a.save(force_insert=True)
|
||||
else:
|
||||
# Check if the name of the note changed without changing the normalized form of the alias
|
||||
alias = Alias.objects.get(normalized_name=Alias.normalize(str(self)))
|
||||
if alias.name != str(self):
|
||||
alias.name = str(self)
|
||||
alias._force_save = True
|
||||
alias.save()
|
||||
|
||||
def clean(self, *args, **kwargs):
|
||||
|
|
|
@ -2743,6 +2743,38 @@
|
|||
"description": "Supprimer une remise"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "permission.permission",
|
||||
"pk": 176,
|
||||
"fields": {
|
||||
"model": [
|
||||
"auth",
|
||||
"user"
|
||||
],
|
||||
"query": "{\"profile__registration_valid\": false}",
|
||||
"type": "change",
|
||||
"mask": 1,
|
||||
"field": "",
|
||||
"permanent": false,
|
||||
"description": "Modifier n'importe quel utilisateur non encore inscrit"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "permission.permission",
|
||||
"pk": 177,
|
||||
"fields": {
|
||||
"model": [
|
||||
"member",
|
||||
"profile"
|
||||
],
|
||||
"query": "{\"registration_valid\": false}",
|
||||
"type": "change",
|
||||
"mask": 1,
|
||||
"field": "",
|
||||
"permanent": false,
|
||||
"description": "Modifier n'importe quel profil non encore inscrit"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "permission.role",
|
||||
"pk": 1,
|
||||
|
@ -2952,7 +2984,9 @@
|
|||
172,
|
||||
173,
|
||||
174,
|
||||
175
|
||||
175,
|
||||
176,
|
||||
177
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -3132,7 +3166,9 @@
|
|||
172,
|
||||
173,
|
||||
174,
|
||||
175
|
||||
175,
|
||||
176,
|
||||
177
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -3164,7 +3200,9 @@
|
|||
167,
|
||||
168,
|
||||
170,
|
||||
171
|
||||
171,
|
||||
176,
|
||||
177
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -3330,10 +3368,13 @@
|
|||
138,
|
||||
139,
|
||||
140,
|
||||
143,
|
||||
145,
|
||||
146,
|
||||
147,
|
||||
150
|
||||
150,
|
||||
176,
|
||||
177
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
@ -293,7 +293,7 @@ class SogeCredit(models.Model):
|
|||
|
||||
@property
|
||||
def valid(self):
|
||||
return self.credit_transaction.valid
|
||||
return self.credit_transaction and self.credit_transaction.valid
|
||||
|
||||
@property
|
||||
def amount(self):
|
||||
|
@ -323,6 +323,7 @@ class SogeCredit(models.Model):
|
|||
# Refresh credit amount
|
||||
self.save()
|
||||
self.credit_transaction.valid = True
|
||||
self.credit_transaction._force_save = True
|
||||
self.credit_transaction.save()
|
||||
self.save()
|
||||
|
||||
|
@ -335,7 +336,7 @@ class SogeCredit(models.Model):
|
|||
@transaction.atomic
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.credit_transaction:
|
||||
self.credit_transaction = SpecialTransaction.objects.create(
|
||||
credit_transaction = SpecialTransaction(
|
||||
source=NoteSpecial.objects.get(special_type="Virement bancaire"),
|
||||
destination=self.user.note,
|
||||
quantity=1,
|
||||
|
@ -346,6 +347,10 @@ class SogeCredit(models.Model):
|
|||
bank="Société générale",
|
||||
valid=False,
|
||||
)
|
||||
credit_transaction._force_save = True
|
||||
credit_transaction.save()
|
||||
credit_transaction.refresh_from_db()
|
||||
self.credit_transaction = credit_transaction
|
||||
elif not self.valid:
|
||||
self.credit_transaction.amount = self.amount
|
||||
self.credit_transaction._force_save = True
|
||||
|
|
|
@ -1017,7 +1017,7 @@ msgstr "Changer le mot de passe"
|
|||
|
||||
#: apps/member/templates/member/includes/profile_info.html:53
|
||||
msgid "API token"
|
||||
msgstr "Acces API"
|
||||
msgstr "Accès API"
|
||||
|
||||
#: apps/member/templates/member/manage_auth_tokens.html:19
|
||||
msgid "Token"
|
||||
|
|
Loading…
Reference in New Issue