2019-08-11 17:55:04 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
from django import forms
|
2020-02-04 00:18:03 +00:00
|
|
|
from .models import TransactionTemplate, Transaction
|
2019-08-11 17:55:04 +00:00
|
|
|
|
|
|
|
class TransactionTemplateForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = TransactionTemplate
|
|
|
|
fields ='__all__'
|
2020-02-04 00:18:03 +00:00
|
|
|
|
|
|
|
class ConsoForm(forms.ModelForm):
|
|
|
|
def save(self, commit=True):
|
|
|
|
button: TransactionTemplate = TransactionTemplate.objects.filter(name=self.data['button']).get()
|
|
|
|
self.instance.destination = button.destination
|
|
|
|
self.instance.amount = button.amount
|
|
|
|
self.instance.transaction_type = 'bouton'
|
|
|
|
self.instance.reason = button.name
|
|
|
|
super().save(commit)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Transaction
|
|
|
|
fields = ('source',)
|