2016-07-19 06:07:49 +00:00
|
|
|
from django import forms
|
2016-07-27 05:08:45 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2016-07-19 06:07:49 +00:00
|
|
|
|
|
|
|
|
2016-07-27 05:08:45 +00:00
|
|
|
from utils.forms import LoginFormMixin, SignupFormMixin, BillingAddressForm
|
|
|
|
from utils.models import BillingAddress
|
|
|
|
|
|
|
|
from .models import Donation, DonatorStatus
|
2016-07-19 06:07:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class LoginForm(LoginFormMixin):
|
|
|
|
email = forms.CharField(widget=forms.EmailInput())
|
|
|
|
password = forms.CharField(widget=forms.PasswordInput())
|
Created signup view. Added login after signup.Added signup url to nosystem app urls.py. Added logout view, Added logout button on nabber, Added password reset form, Added password view , Added password reset html, Added password reset email for nosystemd app. Added confirm_reset_password.html, Added confirm_ reset password view, Added confirm reset password form, Fixed reset password token generation, Started donation view, Added donation view, Added donation.html, Added donation form, Adding donation.js lib in order to capture stripe payments for nosystem app.
2016-07-22 06:24:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SignupForm(SignupFormMixin):
|
2016-07-27 05:08:45 +00:00
|
|
|
confirm_password = forms.CharField(widget=forms.PasswordInput())
|
Created signup view. Added login after signup.Added signup url to nosystem app urls.py. Added logout view, Added logout button on nabber, Added password reset form, Added password view , Added password reset html, Added password reset email for nosystemd app. Added confirm_reset_password.html, Added confirm_ reset password view, Added confirm reset password form, Fixed reset password token generation, Started donation view, Added donation view, Added donation.html, Added donation form, Adding donation.js lib in order to capture stripe payments for nosystem app.
2016-07-22 06:24:32 +00:00
|
|
|
password = forms.CharField(widget=forms.PasswordInput())
|
2016-07-27 05:08:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DonationForm(forms.ModelForm):
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Donation
|
|
|
|
fields = ['donation', 'donator', 'billing_address',
|
|
|
|
'last4', 'cc_brand', 'stripe_charge_id']
|
|
|
|
|
|
|
|
def save(self, commit=True):
|
|
|
|
instance = super(DonationForm, self).save(commit=False)
|
|
|
|
|
|
|
|
if commit:
|
|
|
|
DonatorStatus.create(self.cleaned_data['donator'].user)
|
|
|
|
instance.save()
|
|
|
|
|
|
|
|
return instance
|
|
|
|
|
|
|
|
|
|
|
|
class DonationBillingForm(BillingAddressForm):
|
|
|
|
token = forms.CharField(widget=forms.HiddenInput())
|
|
|
|
donation_amount = forms.FloatField(widget=forms.TextInput(attrs={'placeholder': 'Amount'}))
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = BillingAddress
|
|
|
|
fields = ['donation_amount', 'street_address', 'city', 'postal_code', 'country']
|
|
|
|
labels = {
|
|
|
|
'amount': _('Amount'),
|
|
|
|
'street_address': _('Street Address'),
|
|
|
|
'city': _('City'),
|
|
|
|
'postal_code': _('Postal Code'),
|
|
|
|
'Country': _('Country'),
|
|
|
|
}
|