update dg
This commit is contained in:
		
					parent
					
						
							
								fcc1f8fb4b
							
						
					
				
			
			
				commit
				
					
						0fc96880ef
					
				
			
		
					 105 changed files with 10903 additions and 49 deletions
				
			
		| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
__author__ = 'tomislav'
 | 
			
		||||
from django import forms
 | 
			
		||||
from django.utils.translation import ugettext_lazy as _
 | 
			
		||||
import six
 | 
			
		||||
from django.contrib.auth import authenticate,login
 | 
			
		||||
 | 
			
		||||
from .models import CreditCards
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -15,6 +15,21 @@ class LoginForm(forms.Form):
 | 
			
		|||
                                   attrs={'class': 'form-control', 'placeholder': 'Password',
 | 
			
		||||
                                          'type': 'password'}))
 | 
			
		||||
 | 
			
		||||
    def clean(self):
 | 
			
		||||
        email = self.cleaned_data.get('email')
 | 
			
		||||
        password = self.cleaned_data.get('password')
 | 
			
		||||
        user = authenticate(email=email, password=password)
 | 
			
		||||
        if not user:
 | 
			
		||||
            raise forms.ValidationError("Sorry, that login was invalid. Please try again.")
 | 
			
		||||
        return self.cleaned_data
 | 
			
		||||
 | 
			
		||||
    def login(self,request):
 | 
			
		||||
        username = self.cleaned_data.get('email')
 | 
			
		||||
        password = self.cleaned_data.get('password')
 | 
			
		||||
        user = authenticate(email=username,password=password)
 | 
			
		||||
        return user
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class RegisterForm(LoginForm):
 | 
			
		||||
    name = forms.CharField(label='Name', max_length=50,
 | 
			
		||||
| 
						 | 
				
			
			@ -28,14 +43,16 @@ class PaymentForm(forms.ModelForm):
 | 
			
		|||
        fields = ('name', 'card_number', 'expiry_date', 'ccv', 'user_id')
 | 
			
		||||
        labels = {'name': _('Name'), 'card_number': _('Card number'), 'expiry_date': _('Expiry date'),
 | 
			
		||||
                  'ccv': _('CCV')}
 | 
			
		||||
        exclude = ('user_id','payment_type')
 | 
			
		||||
        exclude = ('user_id', 'payment_type')
 | 
			
		||||
        widgets = {
 | 
			
		||||
            'name': forms.TextInput(
 | 
			
		||||
                attrs={'class': 'form-control', "placeholder": "Enter name on card",
 | 
			
		||||
                       'placeholder': 'Enter name on card'}),
 | 
			
		||||
            'card_number': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Card Number','data-stripe':'number'}),
 | 
			
		||||
            'card_number': forms.TextInput(
 | 
			
		||||
                attrs={'class': 'form-control', 'placeholder': 'Card Number', 'data-stripe': 'number'}),
 | 
			
		||||
            'expiry_date': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'MM/YYYY'}),
 | 
			
		||||
            'ccv': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'CCV','data-stripe':'cvc'})}
 | 
			
		||||
            'ccv': forms.TextInput(
 | 
			
		||||
                attrs={'class': 'form-control', 'placeholder': 'CCV', 'data-stripe': 'cvc'})}
 | 
			
		||||
 | 
			
		||||
    def clean(self):
 | 
			
		||||
        data = self.cleaned_data
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue