Skip to content

Commit

Permalink
Merge 3a99aa7 into c6da9f1
Browse files Browse the repository at this point in the history
  • Loading branch information
Anjaneyulu committed Jul 28, 2016
2 parents c6da9f1 + 3a99aa7 commit 3d5769e
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 3 deletions.
13 changes: 11 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,17 @@ Installation

python setup.py install

2. Add app name in settings.py::

2. After installing/cloning this, add the following settings in the virtual env/bin/activate file to start discussions on blog articles ::
INSTALLED_APPS = [
'..................',
'simple_pagination',
'django_blog_it.django_blog_it',
'..................'
]


3. After installing/cloning this, add the following settings in the virtual env/bin/activate file to start discussions on blog articles ::

You can create your disqus account at https://disqus.com/profile/login/

Expand Down Expand Up @@ -111,7 +120,7 @@ Installation
export DEFAULT_EMAIL


3. Use virtualenv to install requirements::
4. Use virtualenv to install requirements::

pip install -r requirements.txt

Expand Down
12 changes: 12 additions & 0 deletions django_blog_it/django_blog_it/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,15 @@ def __init__(self, *args, **kwargs):
self.fields[field].widget.attrs.update({
'class': 'form-control'
})


class ChangePasswordForm(forms.Form):
password = forms.CharField(widget=forms.PasswordInput(attrs={"class": "form-control"}))
confirm_password = forms.CharField(widget=forms.PasswordInput(attrs={"class": "form-control"}))

def clean_confirm_password(self):
password = self.cleaned_data.get("password")
confirm_password = self.cleaned_data.get("confirm_password")
if password != confirm_password:
raise forms.ValidationError("Passwords do not match!!!")
return confirm_password
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{request.user}} <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{% url 'change_password' %}"><i class="fa fa-key" aria-hidden="true"></i> Change Password</a></li>
<li><a href="{% url 'admin_logout' %}"><i class="fa fa-sign-out"></i> Logout</a></li>
</ul>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% extends 'dashboard/new_base.html' %}
{% block title %}
Change Password
{% endblock %}
{% block content %}
<div class="row no_row_margin heading_count">
<div class="heading col-md-6" id='page_title'>
Change Password
</div>
</div>
<!-- end class of row -->
<div class="row no_row_margin">
<div class="container-fluid">
<form action="" id="post-form" enctype="multipart/form-data" method="post" role="form">
{% csrf_token %}
<div class="row form_row no_row_margin">
<div class="col-md-12">
<div class="col-md-6">
{% for field in form %}
<div class="form-group col-md-12">
<label>{{ field.label }} :</label>
<div class="controls">
{{ field }}
{% if field.help_text %}
<p class="help-inline"><small>{{ field.help_text }}</small></p>
{% endif %}
<p> {{ field.errors }} </p>
</div>
</div>
{% endfor %}
</div>
</div>
<br clear="all">
<div class=" col-md-12 buttons_row text-left">
<div class="form-group">
<button type="submit" class="btn btn-default green_btn"> <i class="fa fa-floppy-o" aria-hidden="true"></i> Submit</button>
<button type="reset" class="btn btn-default blue_btn"> <i class="fa fa-refresh" aria-hidden="true"></i> Reset</button>
</div>
</div>
</div>
</form>
</div>
</div>
<!-- end div row of form -->
{% endblock %}
17 changes: 16 additions & 1 deletion django_blog_it/django_blog_it/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
User = get_user_model()
except ImportError:
from django.contrib.auth.models import User
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.urlresolvers import reverse, reverse_lazy
from django.views.generic import ListView, DetailView, CreateView, DeleteView,\
UpdateView, FormView, TemplateView, View
Expand Down Expand Up @@ -994,7 +995,6 @@ def bulk_actions_themes(request):
messages.warning(request, 'Please select at-least one record to perform this action')
return HttpResponse(json.dumps({'response': False}))


# social login
def google_login(request):
if 'code' in request.GET:
Expand Down Expand Up @@ -1157,3 +1157,18 @@ def facebook_login(request):
else:
rty = "https://graph.facebook.com/oauth/authorize?client_id=" + os.getenv("FB_APP_ID") + "&redirect_uri=" + 'https://' + request.META['HTTP_HOST'] + reverse('facebook_login') + "&scope=manage_pages,read_stream, user_about_me, user_birthday, user_location, user_work_history, user_hometown, user_website, email, user_likes, user_groups"
return HttpResponseRedirect(rty)


class ChangePasswordView(LoginRequiredMixin, FormView):
template_name = "dashboard/user/change_password.html"
form_class = ChangePasswordForm
success_url = reverse_lazy("blog")

def form_valid(self, form):
user = self.request.user
user.set_password(form.cleaned_data.get("password"))
user.save()
user = authenticate(username=user.username, password=form.cleaned_data.get("password"))
login(self.request, user)
messages.success(self.request, "your password has been changed!!!")
return super(ChangePasswordView, self).form_valid(form)
1 change: 1 addition & 0 deletions django_blog_it/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@

url(r'^dashboard/contactUs/$',
configure_contact_us, name='configure_contact_us'),
url(r'^dashboard/change-password/$', ChangePasswordView.as_view(), name='change_password'),

] + static(MEDIA_URL, document_root=MEDIA_ROOT)

0 comments on commit 3d5769e

Please sign in to comment.