123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- from django.utils import timezone
- from django import forms
- from django.contrib.auth.models import User
- from name_extractor.models import Staff
- from django.contrib.auth.forms import UserCreationForm
- from tempus_dominus.widgets import DatePicker
- GOOGLE_CHOICE = [
- (1, '1* rating'),
- (2, '2* rating'),
- (3, '3* rating'),
- (4, '4* rating'),
- (5, '5* rating'),
- (6, 'All Reviews'),
- ]
- FACEBOOK_CHOICE = [
- (1, 'Recommended'),
- (0, 'Not Recommended'),
- (6, 'All Reviews')
- ]
- class UserRegisterForm(UserCreationForm):
- email = forms.EmailField()
- class Meta:
- model = User
- fields = ['username', 'email', 'password1', 'password2']
- class StaffRegistrationForm(forms.ModelForm):
- class Meta:
- model = Staff
- fields = ['name', 'department', 'nick_names']
- class StaffSheetDateForm(forms.Form):
- now = timezone.now()
- today = now.date().strftime('%Y-%m-%d')
- last_month = (now - timezone.timedelta(days=30)).replace(day=now.day).date().strftime('%Y-%m-%d')
- start_date = forms.DateField(
- required=True,
- widget=DatePicker(
- options={
- 'minDate': '2012-01-01',
- 'maxDate': today,
- },
- attrs={
- 'append': 'fa fa-calendar',
- 'icon_toggle': True,
- }
- ),
- initial=last_month,
- )
- end_date = forms.DateField(
- required=True,
- widget=DatePicker(
- options={
- 'minDate': '2012-01-01',
- 'maxDate': today,
- },
- attrs={
- 'append': 'fa fa-calendar',
- 'icon_toggle': True,
- }
- ),
- initial=today,
- )
- class GoogleReviewsFilter(forms.Form):
- now = timezone.now()
- today = now.date().strftime('%Y-%m-%d')
- last_month = (now - timezone.timedelta(days=30)).replace(day=now.day).date().strftime('%Y-%m-%d')
- start_date = forms.DateField(
- required=True,
- widget=DatePicker(
- options={
- 'minDate': '2012-01-01',
- 'maxDate': today,
- },
- attrs={
- 'append': 'fa fa-calendar',
- 'icon_toggle': True,
- }
- ),
- initial=last_month,
- )
- end_date = forms.DateField(
- required=True,
- widget=DatePicker(
- options={
- 'minDate': '2012-01-01',
- 'maxDate': today,
- },
- attrs={
- 'append': 'fa fa-calendar',
- 'icon_toggle': True,
- }
- ),
- initial=today,
- )
- star_ratings = forms.MultipleChoiceField(
- required=False,
- choices=GOOGLE_CHOICE,
- widget=forms.Select(attrs={'class': 'custom-select'}),
- initial=(6, 'All reviews')
- )
- class FacebookReviewsFilter(forms.Form):
- now = timezone.now()
- today = now.date().strftime('%Y-%m-%d')
- last_month = (now - timezone.timedelta(days=30)).replace(day=now.day).date().strftime('%Y-%m-%d')
- start_date = forms.DateField(
- required=True,
- widget=DatePicker(
- options={
- 'minDate': '2012-01-01',
- 'maxDate': today,
- },
- attrs={
- 'append': 'fa fa-calendar',
- 'icon_toggle': True,
- }
- ),
- initial=last_month,
- )
- end_date = forms.DateField(
- required=True,
- widget=DatePicker(
- options={
- 'minDate': '2012-01-01',
- 'maxDate': today,
- },
- attrs={
- 'append': 'fa fa-calendar',
- 'icon_toggle': True,
- }
- ),
- initial=today,
- )
- star_ratings = forms.MultipleChoiceField(
- required=False,
- choices=FACEBOOK_CHOICE,
- widget=forms.Select(attrs={'class': 'custom-select'}),
- initial=(6, 'All Reviews')
- )
|