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