Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model status update on clicking the status displaying anchor tag - code updated and login page validation error fixed #83

Merged
merged 17 commits into from
Jul 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@
<td class="text-center"><input name="bulk_actions" class="bulk_actions" value="{{ category.id }}" type="checkbox"></td>
<td><a href="#">{{ category.name }}</a></td>
<td class="status_on_off text-center">
{% if category.is_active %}
<a href="#" class="status_on" data-toggle="tooltip" data-placement="bottom" title="Active"><i class="fa fa-circle" aria-hidden="true"></i></a>
{% else %}
<a href="#" class="status_off" data-toggle="tooltip" data-placement="bottom" title="In-Active"><i class="fa fa-circle" aria-hidden="true"></i></a>
{% endif %}
<a href="{% url 'category_status_update' category.slug %}" {% if category.is_active %}class="status_on" title="Active"{% else %}class="status_off" title="In-Active"{% endif %} data-toggle="tooltip" data-placement="bottom"><i class="fa fa-circle" aria-hidden="true"></i></a>
</td>
<td class="post_count text-center">
<a href="#">{{ category.category_posts }}</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@
</td>
<td>{{ menu_list.url }}</td>
<td class="status_on_off text-center">
{% if menu_list.status %}
<a href="#" class="status_on" data-toggle="tooltip" data-placement="bottom" title="Active"><i class="fa fa-circle" aria-hidden="true"></i></a>
{% else %}
<a href="#" class="status_off" data-toggle="tooltip" data-placement="bottom" title="In Active"><i class="fa fa-circle" aria-hidden="true"></i></a>
{% endif %}
<a href="{% url 'menu_status_update' menu_list.id %}" {% if menu_list.status %}class="status_on" title="Active" {% else %}class="status_off" title="In Active"{% endif %} data-toggle="tooltip" data-placement="bottom"><i class="fa fa-circle" aria-hidden="true"></i></a>
</td>

{% if request.user.is_superuser %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
$.post(".", $("#admin_login_form").serialize(), function(data){
if(data.error){
$('p.login_error_required').remove();
for (var key in data.response) {
for (var key in data.errors) {
if (key == '__all__'){
$('#'+key).after("<p class='login_error_required text-center'>&nbsp;&nbsp; * " + data.response[key] + "</p>");
$('#'+key).after("<p class='login_error_required text-center'>&nbsp;&nbsp; * " + data.errors[key] + "</p>");
}else{
$('#'+key).after("<p class='login_error_required'>&nbsp;&nbsp; * " + data.response[key] + "</p>");
$('#'+key).after("<p class='login_error_required'>&nbsp;&nbsp; * " + data.errors[key] + "</p>");
}
}
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@
<td><a href="#">{{ page.title }}</a></td>
<td>{{ page.slug }}</td>
<td class="status_on_off text-center">
{% if page.is_active %}
<a href="#" class="status_on" data-toggle="tooltip" data-placement="bottom" title="Active"><i class="fa fa-circle" aria-hidden="true"></i></a>
{% else %}
<a href="#" class="status_off" data-toggle="tooltip" data-placement="bottom" title="In-Active"><i class="fa fa-circle" aria-hidden="true"></i></a>
{% endif %}
<a href="{% url 'page_status_update' page.slug %}" {% if page.is_active %}class="status_on" title="Active"{% else %}class="status_off" title="In-Active"{% endif %} data-toggle="tooltip" data-placement="bottom"><i class="fa fa-circle" aria-hidden="true"></i></a>
</td>
{% if request.user.is_superuser or request.user|get_user_role_name != 'Author' %}
<td class="actions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@
<td class="text-center"><input name="bulk_actions" class="bulk_actions" value="{{ theme.id }}" type="checkbox"></td>
<td><a href="{% url 'view_theme' theme_slug=theme.slug %}">{{ theme.name }}</a></td>
<td class="status_on_off text-center">
{% if theme.enabled %}
<a href="#" class="status_on" data-toggle="tooltip" data-placement="bottom" title="Enabled"><i class="fa fa-circle" aria-hidden="true"></i></a>
{% else %}
<a href="#" class="status_off" data-toggle="tooltip" data-placement="bottom" title="Disabled"><i class="fa fa-circle" aria-hidden="true"></i></a>
{% endif %}
<a href="{% url 'theme_status_update' theme.slug %}" {% if theme.enabled %}class="status_on" title="Enabled"{% else %}class="status_off" title="Disabled"{% endif %} data-toggle="tooltip" data-placement="bottom"><i class="fa fa-circle" aria-hidden="true"></i></a>
</td>
{% if request.user.is_superuser or request.user|get_user_role_name != 'Author' %}
<td class="actions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@
<td><a href="#">{{ user.email }}</a></td>
<td>{{ user.userrole_set.last.role }}</td>
<td class="status_on_off text-center">
{% if user.is_active %}
<a href="#" class="status_on" data-toggle="tooltip" data-placement="bottom" title="Active"><i class="fa fa-circle" aria-hidden="true"></i></a>
{% else %}
<a href="#" class="status_off" data-toggle="tooltip" data-placement="bottom" title="In-Active"><i class="fa fa-circle" aria-hidden="true"></i></a>
{% endif %}
<a href="{% url 'user_status_update' user.id %}" {% if user.is_active %}class="status_on" title="Active"{% else %} class="status_off" title="In-Active"{% endif %} data-toggle="tooltip" data-placement="bottom"><i class="fa fa-circle" aria-hidden="true"></i></a>
</td>
{% if request.user.is_superuser or request.user|get_user_role_name == 'Admin' %}
<td class="text-center post_count"><a href="#"><span data-toggle="tooltip" data-placement="bottom" title="Drafted">{{ user|user_drafted_posts }}</span> / <span data-toggle="tooltip" data-placement="bottom" title="Published">{{ user|user_published_posts }}</span></a></td>
Expand Down
1 change: 1 addition & 0 deletions django_blog_it/django_blog_it/templates/posts/contact.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends 'posts/new_base.html' %}
{% load blog_tags %}
{% block title %} Contact Us {% endblock %}
{% block blog_content %}
<!-- blog_detail_container starts here -->
<div class="blog_detail_container">
Expand Down
57 changes: 57 additions & 0 deletions django_blog_it/django_blog_it/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,17 @@ def form_invalid(self, form):
return JsonResponse({'error': True, 'response': form.errors})


@active_admin_required
def category_status_update(request, category_slug):
category = get_object_or_404(Category, slug=category_slug)
if category.is_active:
category.is_active = False
else:
category.is_active = True
category.save()
return HttpResponseRedirect(reverse_lazy("categories"))


class CategoryDeleteView(AdminMixin, View):

def get(self, request, *args, **kwargs):
Expand Down Expand Up @@ -499,6 +510,17 @@ def form_invalid(self, form):
return JsonResponse({'error': True, 'response': form.errors})


@active_admin_required
def user_status_update(request, pk):
user = get_object_or_404(User, pk=pk)
if user.is_active:
user.is_active = False
else:
user.is_active = True
user.save()
return HttpResponseRedirect(reverse_lazy("users"))


class UserDeleteView(AdminOnlyMixin, View):

def get(self, request, *args, **kwargs):
Expand Down Expand Up @@ -619,6 +641,17 @@ def form_invalid(self, form):
return JsonResponse({'error': True, 'response': form.errors})


@active_admin_required
def page_status_update(request, page_slug):
page = get_object_or_404(Page, slug=page_slug)
if page.is_active:
page.is_active = False
else:
page.is_active = True
page.save()
return HttpResponseRedirect(reverse_lazy("pages"))


class PageDeleteView(AdminMixin, View):

def get(self, request, *args, **kwargs):
Expand Down Expand Up @@ -712,6 +745,17 @@ def form_invalid(self, form):
return JsonResponse({'error': True, 'response': form.errors})


@active_admin_required
def menu_status_update(request, pk):
menu = get_object_or_404(Menu, pk=pk)
if menu.status:
menu.status = False
else:
menu.status = True
menu.save()
return HttpResponseRedirect(reverse_lazy("menus"))


class MenuBulkActionsView(AdminMixin, View):

def get(self, request, *args, **kwargs):
Expand Down Expand Up @@ -885,6 +929,19 @@ def form_invalid(self, form):
return JsonResponse({'error': True, 'response': form.errors})


@active_admin_required
def theme_status_update(request, theme_slug):
blog_theme = get_object_or_404(Theme, slug=theme_slug)
if blog_theme.enabled is True:
blog_theme.enabled = False
else:
Theme.objects.filter(
enabled=True).update(enabled=False)
blog_theme.enabled = True
blog_theme.save()
return HttpResponseRedirect(reverse_lazy("themes"))


@active_admin_required
def edit_theme(request, theme_slug):
theme = get_object_or_404(Theme, slug=theme_slug) # Theme.objects.get(slug=theme_slug)
Expand Down
1 change: 1 addition & 0 deletions django_blog_it/posts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ def contact_us(request):
"keywords": settings.BLOG_KEYWORDS,
"author": settings.BLOG_AUTHOR,
"contact_form": form}

if os.getenv("GOOGLE_CAPTCHA_SITE_KEY"):
context.update({"GOOGLE_CAPTCHA_SITE_KEY": os.getenv("GOOGLE_CAPTCHA_SITE_KEY")})
context.update(categories_tags_lists())
Expand Down
9 changes: 9 additions & 0 deletions django_blog_it/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
url(r'^dashboard/category/add/$', CategoryCreateView.as_view(), name='add_category'),
url(r'^dashboard/category/edit/(?P<category_slug>[-\w]+)/$', CategoryUpdateView.as_view(), name='edit_category'),
url(r'^dashboard/category/delete/(?P<category_slug>[-\w]+)/$', CategoryDeleteView.as_view(), name='delete_category'),
url(r'^dashboard/category/status/(?P<category_slug>[-\w]+)/$', category_status_update, name='category_status_update'),
# pages
url(r'^dashboard/bulk_actions_category/$',
CategoryBulkActionsView.as_view(), name='bulk_actions_category'),
Expand All @@ -48,6 +49,8 @@
url(r'^dashboard/pages/add/$', PageCreateView.as_view(), name='add_page'),
url(r'^dashboard/pages/edit/(?P<page_slug>[-\w]+)/$',
PageUpdateView.as_view(), name='edit_page'),
url(r'^dashboard/pages/update/(?P<page_slug>[-\w]+)/$',
page_status_update, name='page_status_update'),
url(r'^dashboard/pages/delete/(?P<page_slug>[-\w]+)/$',
PageDeleteView.as_view(), name='delete_page'),
url(r'^dashboard/bulk_actions_pages/$',
Expand All @@ -59,6 +62,7 @@
url(r'^dashboard/users/$', UserListView.as_view(), name='users'),
url(r'^dashboard/users/add/$', UserCreateView.as_view(), name='add_user'),
url(r'^dashboard/user/edit/(?P<pk>[-\w]+)/$', UserUpdateView.as_view(), name='edit_user'),
url(r'^dashboard/user/update/(?P<pk>[-\w]+)/$', user_status_update, name='user_status_update'),
url(r'^dashboard/user/edit/(?P<pk>[-\w]+)/user_role/$',
edit_user_role, name='edit_user_role'),
url(r'^dashboard/user/delete/(?P<pk>[-\w]+)/$',
Expand All @@ -70,6 +74,7 @@
url(r'^dashboard/menu/$', MenuListView.as_view(), name='menus'),
url(r'^dashboard/menu/add/$', MenuCreateView.as_view(), name='add_menu'),
url(r'^dashboard/menu/edit/(?P<pk>[-\w]+)/$', MenuUpdateView.as_view(), name='edit_menu'),
url(r'^dashboard/menu/update/(?P<pk>[-\w]+)/$', menu_status_update, name='menu_status_update'),
url(r'^dashboard/bulk_actions_menu/$',
MenuBulkActionsView.as_view(), name='bulk_actions_menu'),

Expand All @@ -95,6 +100,10 @@
url(r'^dashboard/bulk_actions_themes/$',
bulk_actions_themes, name='bulk_actions_themes'),

url(r'^dashboard/themes/update/(?P<theme_slug>[-\w]+)/$',
theme_status_update,
name='theme_status_update'),

url(r'^dashboard/contactUs/$',
configure_contact_us, name='configure_contact_us'),

Expand Down