1
|
|
|
# Copyright 2013 Mathias WOLFF |
2
|
|
|
# This file is part of pyfreebilling. |
3
|
|
|
# |
4
|
|
|
# pyfreebilling is free software: you can redistribute it and/or modify |
5
|
|
|
# it under the terms of the GNU General Public License as published by |
6
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
7
|
|
|
# (at your option) any later version. |
8
|
|
|
# |
9
|
|
|
# pyfreebilling is distributed in the hope that it will be useful, |
10
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12
|
|
|
# GNU General Public License for more details. |
13
|
|
|
# |
14
|
|
|
# You should have received a copy of the GNU General Public License |
15
|
|
|
# along with pyfreebilling. If not, see <http://www.gnu.org/licenses/> |
16
|
|
|
|
17
|
|
|
from django import forms |
18
|
|
|
from django.utils.translation import ugettext_lazy as _ |
19
|
|
|
|
20
|
|
|
from crispy_forms.helper import FormHelper |
21
|
|
|
from crispy_forms.layout import Submit, Layout, Field |
22
|
|
|
from crispy_forms.bootstrap import ( |
23
|
|
|
PrependedText, PrependedAppendedText, FormActions) |
24
|
|
|
|
25
|
|
|
from datetimewidget.widgets import DateTimeWidget |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
class CreateUserForm(forms.Form): |
29
|
|
|
username = forms.CharField(label="Username", required=True) |
30
|
|
|
password = forms.CharField( |
31
|
|
|
label="Password", required=True, widget=forms.PasswordInput) |
32
|
|
|
remember = forms.BooleanField(label="Remember Me?") |
33
|
|
|
|
34
|
|
|
helper = FormHelper() |
35
|
|
|
helper.form_method = 'POST' |
36
|
|
|
helper.add_input(Submit('login', 'login', css_class='btn-primary')) |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
class CartForm(forms.Form): |
40
|
|
|
item = forms.CharField() |
41
|
|
|
quantity = forms.IntegerField(label="Qty") |
42
|
|
|
price = forms.DecimalField() |
43
|
|
|
|
44
|
|
|
helper = FormHelper() |
45
|
|
|
helper.form_method = 'POST' |
46
|
|
|
helper.layout = Layout( |
47
|
|
|
'item', |
48
|
|
|
PrependedText('quantity', '#'), |
49
|
|
|
PrependedAppendedText('price', '$', '.00'), |
50
|
|
|
FormActions(Submit('login', 'login', css_class='btn-primary')) |
51
|
|
|
) |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
class CreditCardForm(forms.Form): |
55
|
|
|
fullname = forms.CharField(label="Full Name", required=True) |
56
|
|
|
card_number = forms.CharField(label="Card", required=True, max_length=16) |
57
|
|
|
expire = forms.DateField(label="Expire Date", input_formats=['%m/%y']) |
58
|
|
|
ccv = forms.IntegerField(label="ccv") |
59
|
|
|
notes = forms.CharField(label="Order Notes", widget=forms.Textarea()) |
60
|
|
|
|
61
|
|
|
helper = FormHelper() |
62
|
|
|
helper.form_method = 'POST' |
63
|
|
|
helper.form_class = 'form-horizontal' |
64
|
|
|
helper.label_class = 'col-sm-2' |
65
|
|
|
helper.field_class = 'col-sm-4' |
66
|
|
|
helper.layout = Layout( |
67
|
|
|
Field('fullname', css_class='input-sm'), |
68
|
|
|
Field('card_number', css_class='input-sm'), |
69
|
|
|
Field('expire', css_class='input-sm'), |
70
|
|
|
Field('ccv', css_class='input-sm'), |
71
|
|
|
Field('notes', rows=3), |
72
|
|
|
FormActions(Submit('purchase', 'purchase', css_class='btn-primary')) |
73
|
|
|
) |
74
|
|
|
|
75
|
|
|
|
76
|
|
|
class CDRSearchForm(forms.Form): |
77
|
|
|
"""VoIP call Report Search Parameters""" |
78
|
|
|
dateTimeOptions = { |
79
|
|
|
'format': 'yyyy-dd-mm hh:ii', |
80
|
|
|
'todayBtn': 'true', |
81
|
|
|
'usetz': 'true', |
82
|
|
|
'usel10n': 'true', |
83
|
|
|
'usei18n': 'true' |
84
|
|
|
} |
85
|
|
|
from_date = forms.CharField( |
86
|
|
|
label=_('From'), |
87
|
|
|
required=False, |
88
|
|
|
max_length=20, |
89
|
|
|
widget=DateTimeWidget(options=dateTimeOptions) |
90
|
|
|
) |
91
|
|
|
to_date = forms.CharField( |
92
|
|
|
label=_('To'), |
93
|
|
|
required=False, |
94
|
|
|
max_length=20, |
95
|
|
|
widget=DateTimeWidget(options=dateTimeOptions) |
96
|
|
|
) |
97
|
|
|
dest_num = forms.IntegerField( |
98
|
|
|
label=_('Destination Number'), |
99
|
|
|
required=False, |
100
|
|
|
help_text=_('Enter the full number or the first part') |
101
|
|
|
) |
102
|
|
|
|
103
|
|
|
|
104
|
|
|
class RatesForm(forms.Form): |
105
|
|
|
ratecard = forms.TypedChoiceField( |
106
|
|
|
label="Select the ratecard", |
107
|
|
|
choices=((1, "Yes"), (0, "No")), |
108
|
|
|
widget=forms.RadioSelect, |
109
|
|
|
initial='1', |
110
|
|
|
required=True, |
111
|
|
|
) |
112
|
|
|
destination = forms.CharField( |
113
|
|
|
label="Destination", |
114
|
|
|
max_length="20", |
115
|
|
|
required=False, |
116
|
|
|
) |
117
|
|
|
prefix = forms.IntegerField( |
118
|
|
|
label='Prefix', |
119
|
|
|
required=False, |
120
|
|
|
) |
121
|
|
|
|
122
|
|
|
def __init__(self, *args, **kwargs): |
123
|
|
|
super(RatesForm, self).__init__(*args, **kwargs) |
124
|
|
|
self.helper = FormHelper() |
125
|
|
|
self.helper.form_id = 'id-exampleForm' |
126
|
|
|
self.helper.form_class = 'form-horizontal' |
127
|
|
|
self.helper.label_class = 'col-lg-2' |
128
|
|
|
self.helper.field_class = 'col-lg-8' |
129
|
|
|
self.helper.form_method = 'post' |
130
|
|
|
self.helper.form_action = 'list_rates' |
131
|
|
|
self.helper.add_input(Submit('submit', 'Submit')) |
132
|
|
|
|