From e8963460df27409870a45f6bc287bc97b9045999 Mon Sep 17 00:00:00 2001 From: Jailson Dias Date: Mon, 26 Sep 2016 10:32:33 -0300 Subject: [PATCH] template de criar enquete #77 --- core/templates/base.html | 6 +++--- core/templates/index.html | 5 +---- courses/models.py | 24 +++++++++++++++++++++++- courses/templates/poll/poll.html | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ courses/urls.py | 3 ++- courses/views.py | 27 ++++++++++++++++++++++++--- 6 files changed, 106 insertions(+), 12 deletions(-) create mode 100644 courses/templates/poll/poll.html diff --git a/core/templates/base.html b/core/templates/base.html index b88608a..a06c8d5 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -18,8 +18,7 @@ - {% block style %} - {% endblock %} + @@ -32,7 +31,8 @@ - + {% block style %} + {% endblock %}
diff --git a/core/templates/index.html b/core/templates/index.html index 6603763..6e34a4d 100644 --- a/core/templates/index.html +++ b/core/templates/index.html @@ -41,7 +41,6 @@ {% endif %}
- {#
#}
{% csrf_token %}
@@ -64,10 +63,8 @@
- {#
#} - {# #} {#
#} diff --git a/courses/models.py b/courses/models.py index 79e1767..3d1c0ba 100644 --- a/courses/models.py +++ b/courses/models.py @@ -102,4 +102,26 @@ class Material(Resource): topic = models.ForeignKey(Topic, verbose_name = _('Topic')) student = models.ForeignKey(User, verbose_name = _('student')) - +class Poll(Activity): + question = models.CharField(_('Question'), max_length = 300) + + class Meta: + ordering = ('create_date','name') + verbose_name = _('Poll') + verbose_name_plural = _('Polls') + + def __str__(self): + return str(self.question) + str("/") + str(self.topic) + +class Answer(models.Model): + answer = models.CharField(_("Answer"), max_length = 200) + order = models.PositiveSmallIntegerField(_("Order")) + poll = models.ForeignKey(Poll, verbose_name = _('Answers'), related_name='answers') + + class Meta: + ordering = ('order',) + verbose_name = _('Answer') + verbose_name_plural = _('Answers') + + def __str__(self): + return str(self.question) + str("/") + str(self.topic) diff --git a/courses/templates/poll/poll.html b/courses/templates/poll/poll.html new file mode 100644 index 0000000..4aa8460 --- /dev/null +++ b/courses/templates/poll/poll.html @@ -0,0 +1,53 @@ +{% extends "topic/index.html" %} + +{% load i18n %} + +{% block style %} + +{% endblock %} + +{% block content %} +
+
+
+

+ Question?

+
+
+
+
+
+
+ +
+
+
+ + Please enter a valid email address +
+
+
+
+ +
+
+
+
+
+ +
+ +
+ +{% endblock content %} diff --git a/courses/urls.py b/courses/urls.py index cca15f0..b384496 100644 --- a/courses/urls.py +++ b/courses/urls.py @@ -20,5 +20,6 @@ urlpatterns = [ url(r'^subjects/delete/(?P[\w_-]+)/$', views.DeleteSubjectView.as_view(), name='delete_subject'), url(r'^topics/create/(?P[\w_-]+)/$', views.CreateTopicView.as_view(), name='create_topic'), url(r'^topics/update/(?P[\w_-]+)/$', views.UpdateTopicView.as_view(), name='update_topic'), - url(r'^topics/(?P[\w_-]+)/$', views.TopicsView.as_view(), name='view_topic') + url(r'^topics/(?P[\w_-]+)/$', views.TopicsView.as_view(), name='view_topic'), + url(r'^to/poll/to/$', views.Poll.as_view(), name='poll'), ] diff --git a/courses/views.py b/courses/views.py index ea1025b..91a70fe 100644 --- a/courses/views.py +++ b/courses/views.py @@ -309,9 +309,7 @@ class CreateTopicView(LoginRequiredMixin, HasRoleMixin, NotificationMixin, gener subject = get_object_or_404(Subject, slug = self.kwargs.get('slug')) context['course'] = subject.course context['subject'] = subject - context['subjects'] = subject.course.subjects.filter(Q(visible=True) | Q(professors__in=[self.request.user])) - if (has_role(self.request.user,'system_admin')): - context['subjects'] = subject.course.subjects.all() + context['subjects'] = subject.course.subjects.all() return context def form_valid(self, form): @@ -441,3 +439,26 @@ class DeleteSubjectView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): def get_success_url(self): return reverse_lazy('course:view', kwargs={'slug' : self.object.course.slug}) + + +class Poll(generic.TemplateView): + + # login_url = reverse_lazy("core:home") + # redirect_field_name = 'next' + # model = Course + # context_object_name = 'course' + template_name = 'poll/poll.html' + # queryset = Course.objects.all() + + # def get_queryset(self): + # return Course.objects.all()[0] + + def get_context_data(self, **kwargs): + context = super(Poll, self).get_context_data(**kwargs) + course = Course.objects.all()[0] + context['course'] = course + context['subject'] = course.subjects.all()[0] + context['subjects'] = course.subjects.all() + # if (has_role(self.request.user,'system_admin')): + # context['subjects'] = self.object.course.subjects.all() + return context -- libgit2 0.21.2