mirror of
https://github.com/Lyxminxx/jast.git
synced 2026-10-11 12:51:51 +02:00
redesign, added user system, added api endpoints
This commit is contained in:
1 parent
2c76e1df78
commit
72b8e569aa
17 files changed
+782
-99
No files matched your search
+19
-4
@@ -1,11 +1,26 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django.contrib.auth.models import User
|
||||
from .models import Transaction
|
||||
|
||||
class TransactionForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Transaction
|
||||
fields = ['title', 'amount', 'category', 'date']
|
||||
# This widget forces the browser to show a date picker calendar
|
||||
widgets = {
|
||||
'date': forms.DateInput(attrs={'type': 'date'}),
|
||||
}
|
||||
|
||||
|
||||
class CustomUserCreationForm(UserCreationForm):
|
||||
first_name = forms.CharField(max_length=30, required=True, label="First Name")
|
||||
last_name = forms.CharField(max_length=30, required=True, label="Last Name")
|
||||
|
||||
class Meta(UserCreationForm.Meta):
|
||||
model = User
|
||||
fields = UserCreationForm.Meta.fields + ('first_name', 'last_name')
|
||||
|
||||
def save(self, commit=True):
|
||||
user = super().save(commit=False)
|
||||
user.first_name = self.cleaned_data['first_name']
|
||||
user.last_name = self.cleaned_data['last_name']
|
||||
if commit:
|
||||
user.save()
|
||||
return user
|
||||
Reference in new issue
Block a user