mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-26 18:37:12 +00:00
Fix registration permissions and procedure
This commit is contained in:
parent
73ca65aa91
commit
180cd3e1ec
@ -477,8 +477,13 @@ class Membership(models.Model):
|
|||||||
# to treasurers.
|
# to treasurers.
|
||||||
transaction.valid = False
|
transaction.valid = False
|
||||||
from treasury.models import SogeCredit
|
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.refresh_from_db()
|
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.save(force_insert=True)
|
||||||
transaction.refresh_from_db()
|
transaction.refresh_from_db()
|
||||||
soge_credit.transactions.add(transaction)
|
soge_credit.transactions.add(transaction)
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<dt class="col-xl-6">{% trans 'address'|capfirst %}</dt>
|
<dt class="col-xl-6">{% trans 'address'|capfirst %}</dt>
|
||||||
<dd class="col-xl-6">{{ user_object.profile.address }}</dd>
|
<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>
|
<dt class="col-xl-6">{% trans 'balance'|capfirst %}</dt>
|
||||||
<dd class="col-xl-6">{{ user_object.note.balance | pretty_money }}</dd>
|
<dd class="col-xl-6">{{ user_object.note.balance | pretty_money }}</dd>
|
||||||
|
|
||||||
@ -47,7 +47,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
{% if user_object.pk == user_object.pk %}
|
{% if user_object.pk == user.pk %}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<a class="small badge badge-secondary" href="{% url 'member:auth_token' %}">
|
<a class="small badge badge-secondary" href="{% url 'member:auth_token' %}">
|
||||||
<i class="fa fa-cogs"></i>{% trans 'API token' %}
|
<i class="fa fa-cogs"></i>{% trans 'API token' %}
|
||||||
|
@ -109,12 +109,16 @@ class Note(PolymorphicModel):
|
|||||||
|
|
||||||
# Save alias
|
# Save alias
|
||||||
a.note = self
|
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)
|
a.save(force_insert=True)
|
||||||
else:
|
else:
|
||||||
# Check if the name of the note changed without changing the normalized form of the alias
|
# 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)))
|
alias = Alias.objects.get(normalized_name=Alias.normalize(str(self)))
|
||||||
if alias.name != str(self):
|
if alias.name != str(self):
|
||||||
alias.name = str(self)
|
alias.name = str(self)
|
||||||
|
alias._force_save = True
|
||||||
alias.save()
|
alias.save()
|
||||||
|
|
||||||
def clean(self, *args, **kwargs):
|
def clean(self, *args, **kwargs):
|
||||||
|
@ -2743,6 +2743,38 @@
|
|||||||
"description": "Supprimer une remise"
|
"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",
|
"model": "permission.role",
|
||||||
"pk": 1,
|
"pk": 1,
|
||||||
@ -2952,7 +2984,9 @@
|
|||||||
172,
|
172,
|
||||||
173,
|
173,
|
||||||
174,
|
174,
|
||||||
175
|
175,
|
||||||
|
176,
|
||||||
|
177
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -3132,7 +3166,9 @@
|
|||||||
172,
|
172,
|
||||||
173,
|
173,
|
||||||
174,
|
174,
|
||||||
175
|
175,
|
||||||
|
176,
|
||||||
|
177
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -3164,7 +3200,9 @@
|
|||||||
167,
|
167,
|
||||||
168,
|
168,
|
||||||
170,
|
170,
|
||||||
171
|
171,
|
||||||
|
176,
|
||||||
|
177
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -3330,10 +3368,13 @@
|
|||||||
138,
|
138,
|
||||||
139,
|
139,
|
||||||
140,
|
140,
|
||||||
|
143,
|
||||||
145,
|
145,
|
||||||
146,
|
146,
|
||||||
147,
|
147,
|
||||||
150
|
150,
|
||||||
|
176,
|
||||||
|
177
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -293,7 +293,7 @@ class SogeCredit(models.Model):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def valid(self):
|
def valid(self):
|
||||||
return self.credit_transaction.valid
|
return self.credit_transaction and self.credit_transaction.valid
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def amount(self):
|
def amount(self):
|
||||||
@ -323,6 +323,7 @@ class SogeCredit(models.Model):
|
|||||||
# Refresh credit amount
|
# Refresh credit amount
|
||||||
self.save()
|
self.save()
|
||||||
self.credit_transaction.valid = True
|
self.credit_transaction.valid = True
|
||||||
|
self.credit_transaction._force_save = True
|
||||||
self.credit_transaction.save()
|
self.credit_transaction.save()
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
@ -335,7 +336,7 @@ class SogeCredit(models.Model):
|
|||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if not self.credit_transaction:
|
if not self.credit_transaction:
|
||||||
self.credit_transaction = SpecialTransaction.objects.create(
|
credit_transaction = SpecialTransaction(
|
||||||
source=NoteSpecial.objects.get(special_type="Virement bancaire"),
|
source=NoteSpecial.objects.get(special_type="Virement bancaire"),
|
||||||
destination=self.user.note,
|
destination=self.user.note,
|
||||||
quantity=1,
|
quantity=1,
|
||||||
@ -346,6 +347,10 @@ class SogeCredit(models.Model):
|
|||||||
bank="Société générale",
|
bank="Société générale",
|
||||||
valid=False,
|
valid=False,
|
||||||
)
|
)
|
||||||
|
credit_transaction._force_save = True
|
||||||
|
credit_transaction.save()
|
||||||
|
credit_transaction.refresh_from_db()
|
||||||
|
self.credit_transaction = credit_transaction
|
||||||
elif not self.valid:
|
elif not self.valid:
|
||||||
self.credit_transaction.amount = self.amount
|
self.credit_transaction.amount = self.amount
|
||||||
self.credit_transaction._force_save = True
|
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
|
#: apps/member/templates/member/includes/profile_info.html:53
|
||||||
msgid "API token"
|
msgid "API token"
|
||||||
msgstr "Acces API"
|
msgstr "Accès API"
|
||||||
|
|
||||||
#: apps/member/templates/member/manage_auth_tokens.html:19
|
#: apps/member/templates/member/manage_auth_tokens.html:19
|
||||||
msgid "Token"
|
msgid "Token"
|
||||||
|
Loading…
Reference in New Issue
Block a user