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 3978a2e8..2faee857 100644 --- a/project/templates/lilcity/index.html +++ b/project/templates/lilcity/index.html @@ -135,16 +135,14 @@ {% 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}} - - {% else %} - - {% endif %} - {% endwith %} + {% if request.user.auth_token %} + {% if request.user.role == 1 or request.user.role == 2 %} + + {% comment %} {% endcomment %}
ДОБАВИТЬ КУРС
+ {% endif %} + {% endif %}
ПРОФИЛЬ
diff --git a/project/urls.py b/project/urls.py index 65451425..94812354 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'),