1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# This file is part of the Taler Codeless Merchant.
# (C) 2018 GNUnet e.V.
#
# The Taler Codeless Merchant is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# The Taler Codeless Merchant is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
# for more details.
#
# You should have received a copy of the GNU Affero General Public License along
# with the Taler Codeless Merchant. If not, see <https://www.gnu.org/licenses/>.
#
# @author Shivam Kohli
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from inventory.models import Merchant, Product
ADDRESS_CHOICES= [
('sepa', 'SEPA'),
('upi', 'UPI'),
('bitcoin', 'BITCOIN'),
('ach', 'ACH'),
]
class SignUpForm(UserCreationForm):
first_name = forms.CharField(max_length=30, required=False)
last_name = forms.CharField(max_length=30, required=False)
email = forms.EmailField(max_length=254)
website = forms.URLField(label='Enter website URL', max_length=250, required=False)
address = forms.CharField(label='Payment Address type', widget=forms.Select(choices=ADDRESS_CHOICES))
pay_url = forms.URLField(label='Directly enter the Plain PaytoURI', max_length=250, required=False)
class Meta:
model = User
fields = (
'username',
'first_name',
'last_name',
'email',
'password1',
'password2',
'address',
'pay_url',
'website'
)
def __init__(self, *args, **kwargs):
super(SignUpForm, self).__init__(*args, **kwargs)
for fieldname in ['username', 'password1', 'password2']:
self.fields[fieldname].help_text = None
class LoginForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput)
class Meta:
model = User
fields = (
"username",
"password"
)
def __init__(self, *args, **kwargs):
super(LoginForm, self).__init__(*args, **kwargs)
for fieldname in ['username', 'password']:
self.fields[fieldname].help_text = None
class DocumentForm(forms.ModelForm):
class Meta:
model = Product
fields = ('name', 'price', 'description', 'document', )
|