forked from DGNum/gestioCOF
Création auto des settings si inexistant
- S'effectue en allant sur la page `Paramètres` (perm `kfet.change_settings` nécessaires même pour voir les paramètres) - Correction websocket perform operations lorsqu'il n'y avait pas de majorations en cours
This commit is contained in:
parent
ee998f8a24
commit
7ca123e885
2 changed files with 29 additions and 1 deletions
|
@ -550,5 +550,29 @@ class Settings(models.Model):
|
||||||
except Settings.DoesNotExist:
|
except Settings.DoesNotExist:
|
||||||
return timedelta()
|
return timedelta()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create_missing():
|
||||||
|
s, created = Settings.objects.get_or_create(name='SUBVENTION_COF')
|
||||||
|
if created:
|
||||||
|
s.value_decimal = 25
|
||||||
|
s.save()
|
||||||
|
s, created = Settings.objects.get_or_create(name='ADDCOST_AMOUNT')
|
||||||
|
if created:
|
||||||
|
s.value_decimal = 0.5
|
||||||
|
s.save()
|
||||||
|
s, created = Settings.objects.get_or_create(name='ADDCOST_FOR')
|
||||||
|
s, created = Settings.objects.get_or_create(name='OVERDRAFT_DURATION')
|
||||||
|
if created:
|
||||||
|
s.value_duration = timedelta(days=1) # 24h
|
||||||
|
s.save()
|
||||||
|
s, created = Settings.objects.get_or_create(name='OVERDRAFT_AMOUNT')
|
||||||
|
if created:
|
||||||
|
s.value_decimal = 20
|
||||||
|
s.save()
|
||||||
|
s, created = Settings.objects.get_or_create(name='CANCEL_DURATION')
|
||||||
|
if created:
|
||||||
|
s.value_duration = timedelta(minutes=5) # 5min
|
||||||
|
s.save()
|
||||||
|
|
||||||
class GenericTeamToken(models.Model):
|
class GenericTeamToken(models.Model):
|
||||||
token = models.CharField(max_length = 50, unique = True)
|
token = models.CharField(max_length = 50, unique = True)
|
||||||
|
|
|
@ -670,7 +670,7 @@ def kpsul_perform_operations(request):
|
||||||
ope_data = {
|
ope_data = {
|
||||||
'id': operation.pk, 'type': operation.type, 'amount': operation.amount,
|
'id': operation.pk, 'type': operation.type, 'amount': operation.amount,
|
||||||
'addcost_amount': operation.addcost_amount,
|
'addcost_amount': operation.addcost_amount,
|
||||||
'addcost_for': addcost_for.trigramme,
|
'addcost_for': is_addcost and addcost_for.trigramme or None,
|
||||||
'is_checkout': operation.is_checkout,
|
'is_checkout': operation.is_checkout,
|
||||||
'article__name': operation.article and operation.article.name or None,
|
'article__name': operation.article and operation.article.name or None,
|
||||||
'article_nb': operation.article_nb,
|
'article_nb': operation.article_nb,
|
||||||
|
@ -878,6 +878,10 @@ class SettingsList(ListView):
|
||||||
context_object_name = 'settings'
|
context_object_name = 'settings'
|
||||||
template_name = 'kfet/settings.html'
|
template_name = 'kfet/settings.html'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
Settings.create_missing()
|
||||||
|
return super(SettingsList, self).get_context_data(**kwargs)
|
||||||
|
|
||||||
class SettingsUpdate(SuccessMessageMixin, UpdateView):
|
class SettingsUpdate(SuccessMessageMixin, UpdateView):
|
||||||
model = Settings
|
model = Settings
|
||||||
form_class = SettingsForm
|
form_class = SettingsForm
|
||||||
|
|
Loading…
Reference in a new issue