digitalglarus booking update

This commit is contained in:
Tomislav R 2016-04-23 19:00:20 +02:00
commit ae0c404951
22 changed files with 5935 additions and 3794 deletions

View file

@ -1,10 +1,13 @@
from datetime import datetime
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User, AbstractBaseUser, BaseUserManager,AbstractUser
from django.contrib.auth.models import User, AbstractBaseUser, BaseUserManager, AbstractUser
from django.contrib.auth.hashers import make_password
from django.core.mail import send_mail
from django.core.validators import RegexValidator
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
REGISTRATION_MESSAGE = {'subject': "Validation mail",
'message': 'Please validate Your account under this link http://localhost:8000/en-us/login/validate/{}',
@ -43,6 +46,7 @@ class MyUserManager(BaseUserManager):
class CustomUser(AbstractBaseUser):
VALIDATED_CHOICES = ((0, 'Not validated'), (1, 'Validated'))
site = models.ForeignKey(Site, default=1)
name = models.CharField(max_length=50)
email = models.EmailField(unique=True)
@ -123,5 +127,26 @@ class CreditCards(models.Model):
card_number = models.CharField(max_length=50)
expiry_date = models.CharField(max_length=50, validators=[RegexValidator(r'\d{2}\/\d{4}', _(
'Use this pattern(MM/YYYY).'))])
ccv = models.CharField(max_length=4,validators=[RegexValidator(r'\d{3,4}',_('Wrong CCV number.'))])
payment_type = models.CharField(max_length=5,default='N')
ccv = models.CharField(max_length=4, validators=[RegexValidator(r'\d{3,4}', _('Wrong CCV number.'))])
payment_type = models.CharField(max_length=5, default='N')
class Calendar(models.Model):
datebooked = models.DateField()
user = models.ForeignKey(CustomUser)
def __init__(self, *args, **kwargs):
if kwargs.get('datebooked'):
user = kwargs.get('user')
kwargs['datebooked'] = datetime.strptime(kwargs.get('datebooked', ''), '%d,%m,%Y')
self.user_id = user.id
super(Calendar, self).__init__(*args, **kwargs)
@classmethod
def add_dates(cls,dates,user):
old_dates = Calendar.objects.filter(user_id=user.id)
if old_dates:
old_dates.delete()
for date in dates:
Calendar.objects.create(datebooked=date,user=user)