Skip to content

Commit

Permalink
new design templates integrated for django_blot_it app
Browse files Browse the repository at this point in the history
new design templates integrated for django_blot_it app
  • Loading branch information
vidyasagar-r authored and ashwin31 committed Jul 1, 2016
1 parent 32e0532 commit b43a86a
Show file tree
Hide file tree
Showing 24 changed files with 2,234 additions and 119 deletions.
59 changes: 57 additions & 2 deletions django_blog_it/django_blog_it/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,46 @@
from django.template.defaultfilters import slugify
# for authentication
from django.contrib.auth import authenticate
from django.contrib.auth.models import User


class UserForm(forms.ModelForm):
password = forms.CharField(required=False, widget=forms.PasswordInput)

class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password', 'is_active')

def clean_email(self):
email = self.cleaned_data.get('email')
username = self.cleaned_data.get('username')
if self.instance:
if User.objects.filter(email=email, username=username).exclude(id=self.instance.id).count():
raise forms.ValidationError(u'Email addresses must be unique.')
else:
if User.objects.filter(email=email).exclude(username=username).count():
raise forms.ValidationError(u'Email addresses must be unique.')
return email

def __init__(self, *args, **kwargs):
super(UserForm, self).__init__(*args, **kwargs)
self.fields['email'].required = True
for field in iter(self.fields):
if max(enumerate(iter(self.fields)))[0] != field:
self.fields[field].widget.attrs.update({
'class': 'form-control',
"placeholder": "Please enter your " + field.capitalize()
})

def save(self, commit=True):
user = super(UserForm, self).save(commit=False)
password = self.cleaned_data["password"]
if password:
user.set_password(password)
if commit:
user.save()
return user

class AdminLoginForm(forms.Form):
username = forms.CharField(max_length=254)
password = forms.CharField(label="Password", widget=forms.PasswordInput)
Expand All @@ -15,7 +53,7 @@ def clean(self):
if username and password:
user = authenticate(username=username, password=password)
if user is None:
raise forms.ValidationError("Incorrect login details")
raise forms.ValidationError("Incorrect Login Details")

return self.cleaned_data

Expand Down Expand Up @@ -67,7 +105,7 @@ def __init__(self, *args, **kwargs):
super(BlogCategoryForm, self).__init__(*args, **kwargs)

for field in iter(self.fields):
if max(enumerate(iter(self.fields)))[1] != field:
if max(enumerate(iter(self.fields)))[0] != field:
self.fields[field].widget.attrs.update({
'class': 'form-control', "placeholder": "Please enter your Category " + field.capitalize()
})
Expand All @@ -82,12 +120,29 @@ class Meta:
model = Page
exclude = ('slug',)

def __init__(self, *args, **kwargs):
super(PageForm, self).__init__(*args, **kwargs)

for field in iter(self.fields):
if max(enumerate(iter(self.fields)))[0] != field:
self.fields[field].widget.attrs.update({
'class': 'form-control', "placeholder": "Please enter your Page " + field.capitalize()
})


class MenuForm(forms.ModelForm):
class Meta:
model = Menu
exclude = ('lvl',)

def __init__(self, *args, **kwargs):
super(MenuForm, self).__init__(*args, **kwargs)

for field in iter(self.fields):
if max(enumerate(iter(self.fields)))[0] != field:
self.fields[field].widget.attrs.update({
'class': 'form-control', "placeholder": "Please enter your Menu " + field.capitalize()
})

class ContactUsSettingsForm(forms.ModelForm):

Expand Down
3 changes: 3 additions & 0 deletions django_blog_it/django_blog_it/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def save(self, *args, **kwargs):
def __str__(self):
return self.name

def category_posts(self):
return Post.objects.filter(category=self).count()


class Tags(models.Model):
name = models.CharField(max_length=20, unique=True)
Expand Down
62 changes: 55 additions & 7 deletions django_blog_it/django_blog_it/static/css/jquery.tagsinput.css
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,55 @@
div.tagsinput { border:1px solid #CCC; background: #FFF; padding:5px; width:300px; height:100px; overflow-y: auto;}
div.tagsinput span.tag { border: 1px solid #a5d24a; -moz-border-radius:2px; -webkit-border-radius:2px; display: block; float: left; padding: 5px; text-decoration:none; background: #cde69c; color: #638421; margin-right: 5px; margin-bottom:5px;font-family: helvetica; font-size:13px;}
div.tagsinput span.tag a { font-weight: bold; color: #82ad2b; text-decoration:none; font-size: 11px; }
div.tagsinput input { width:80px; margin:0px; font-family: helvetica; font-size: 13px; border:1px solid transparent; padding:5px; background: transparent; color: #000; outline:0px; margin-right:5px; margin-bottom:5px; }
div.tagsinput div { display:block; float: left; }
.tags_clear { clear: both; width: 100%; height: 0px; }
.not_valid {background: #FBD8DB !important; color: #90111A !important;}
div.tagsinput {
overflow-y: auto;
background: #fff;
border-radius: 0px;
padding: 7px 10px;
border: none;
min-height: 42px !important;
font-size: 12px;
box-shadow: none;
border:1px solid #D9D9D9 !important;
}
div.tagsinput span.tag {
display: block;
float: left;
padding: 5px;
text-decoration: none;
background: #7D8590;
color: #fff;
margin-right: 5px;
margin-bottom: 5px;
font-size: 13px;
font-weight:normal;
}
div.tagsinput span.tag a {
font-weight: bold;
color: #fff;
text-decoration: none;
font-size: 11px;
}

div.tagsinput input {
width: 80px;
margin: 0px;
font-family: 'Lato', sans-serif;
font-size: 13px;
border: 1px solid transparent;
padding: 5px;
background: transparent;
color: #505458 !important;
outline: 0px;
margin-right: 5px;
}
div.tagsinput div {
display: block;
float: left;
}
.tags_clear {
clear: both;
width: 100%;
height: 0px;
}
.not_valid {
background: #FBD8DB !important;
color: #90111A !important;
}

0 comments on commit b43a86a

Please sign in to comment.