From 89d23f11a3d6231ba62924732347cd17a2e90517 Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Tue, 13 Feb 2018 13:51:59 +0300 Subject: [PATCH 1/3] Fix user menu --- project/templates/lilcity/index.html | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/project/templates/lilcity/index.html b/project/templates/lilcity/index.html index 9f6273b4..2737a719 100644 --- a/project/templates/lilcity/index.html +++ b/project/templates/lilcity/index.html @@ -135,14 +135,13 @@ {% endif %}
{% comment %} 234.120.345 руб. {% endcomment %} - {% with roles='author admin' %} - {% if request.user.role in roles.split and request.user.auth_token %} - {{request.user.auth_token}} + {% if request.user.auth_token %} + {% if request.user.role == 1 or request.user.role == 2 %} {% else %} {% endif %} - {% endwith %} + {% endif %}
ДОБАВИТЬ КУРС
From d9564b6fec064e75ab75bbe521e426b525212775 Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Tue, 13 Feb 2018 14:01:07 +0300 Subject: [PATCH 2/3] Fix create link and view --- apps/course/views.py | 8 ++++++-- project/templates/lilcity/index.html | 2 +- project/urls.py | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/course/views.py b/apps/course/views.py index 1b79be28..80a5af8d 100644 --- a/apps/course/views.py +++ b/apps/course/views.py @@ -141,12 +141,16 @@ class CourseEditView(TemplateView): template_name = 'course/course_edit.html' def get(self, request, pk=None): - self.object = get_object_or_404(Course, pk=pk) + if pk: + self.object = get_object_or_404(Course, pk=pk) + else: + self.object = None return super().get(request) def get_context_data(self): context = super().get_context_data() - context['course'] = self.object + if self.object: + context['course'] = self.object return context diff --git a/project/templates/lilcity/index.html b/project/templates/lilcity/index.html index 2737a719..c3b89cef 100644 --- a/project/templates/lilcity/index.html +++ b/project/templates/lilcity/index.html @@ -137,7 +137,7 @@ {% comment %} 234.120.345 руб. {% endcomment %} {% if request.user.auth_token %} {% if request.user.role == 1 or request.user.role == 2 %} - + {% else %} {% endif %} diff --git a/project/urls.py b/project/urls.py index a0754311..9795639a 100644 --- a/project/urls.py +++ b/project/urls.py @@ -33,7 +33,8 @@ urlpatterns = [ path('course//', CourseView.as_view(), name='course'), path('course//', CourseView.as_view(), name='course'), path('course//like', likes, name='likes'), - path('course//edit', CourseEditView.as_view(), name='course-edit'), + path('course/create', CourseEditView.as_view(), name='course_create'), + path('course//edit', CourseEditView.as_view(), name='course_edit'), path('course//comment', coursecomment, name='coursecomment'), path('lesson//', LessonView.as_view(), name='lesson'), path('lesson//comment', lessoncomment, name='lessoncomment'), From 9a84fb7c6f1b906978efdd8927869e110f0f0a1d Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Tue, 13 Feb 2018 14:27:34 +0300 Subject: [PATCH 3/3] Dont show add course menu item if user not have perms --- project/templates/lilcity/index.html | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/project/templates/lilcity/index.html b/project/templates/lilcity/index.html index c3b89cef..eddb7422 100644 --- a/project/templates/lilcity/index.html +++ b/project/templates/lilcity/index.html @@ -138,12 +138,11 @@ {% if request.user.auth_token %} {% if request.user.role == 1 or request.user.role == 2 %} - {% else %} - - {% endif %} - {% endif %} + {% comment %} {% endcomment %}
ДОБАВИТЬ КУРС
+ {% endif %} + {% endif %}
ПРОФИЛЬ