Commit e8963460df27409870a45f6bc287bc97b9045999
1 parent
4a4e0103
Exists in
master
and in
5 other branches
template de criar enquete #77
Showing
6 changed files
with
106 additions
and
12 deletions
Show diff stats
core/templates/base.html
... | ... | @@ -18,8 +18,7 @@ |
18 | 18 | <link rel="stylesheet" type="text/css" href="{% static 'css/base/header.css' %}"> |
19 | 19 | <link rel="stylesheet" type="text/css" href="{% static 'css/base/amadeus.css' %}"> |
20 | 20 | <!--CSS block for specific-app ones --> |
21 | - {% block style %} | |
22 | - {% endblock %} | |
21 | + | |
23 | 22 | |
24 | 23 | <link href="{% static 'img/favicon.ico' %}" rel="shortcut icon" /> |
25 | 24 | |
... | ... | @@ -32,7 +31,8 @@ |
32 | 31 | </script> |
33 | 32 | <script src="{% static 'js/base/header.js'%}"></script> |
34 | 33 | <!--Javascript block for specific-app ones --> |
35 | - | |
34 | + {% block style %} | |
35 | + {% endblock %} | |
36 | 36 | </head> |
37 | 37 | <body> |
38 | 38 | <div class="container-fluid"> | ... | ... |
core/templates/index.html
... | ... | @@ -41,7 +41,6 @@ |
41 | 41 | {% endif %} |
42 | 42 | <div class="card"> |
43 | 43 | <div class="card-block"> |
44 | - {# <div class="row"> #} | |
45 | 44 | <form id="form-login" class="form-group" method="post" action=""> |
46 | 45 | {% csrf_token %} |
47 | 46 | <div class="form-group is-empty"> |
... | ... | @@ -64,10 +63,8 @@ |
64 | 63 | </div> |
65 | 64 | </div> |
66 | 65 | </form> |
67 | - {# </div> #} | |
68 | - {# <div class="row"> #} | |
69 | 66 | <div class="col-md-10 col-sm-10 col-xs-10 col-lg-10"> |
70 | - <a href="{% url 'core:remember_password' %}">Forgot your password?</a> | |
67 | + <a href="{% url 'core:remember_password' %}">{% trans "Forgot your password?" %}</a> | |
71 | 68 | </div> |
72 | 69 | {# </div> #} |
73 | 70 | {# <div class="row"> #} | ... | ... |
courses/models.py
... | ... | @@ -102,4 +102,26 @@ class Material(Resource): |
102 | 102 | topic = models.ForeignKey(Topic, verbose_name = _('Topic')) |
103 | 103 | student = models.ForeignKey(User, verbose_name = _('student')) |
104 | 104 | |
105 | - | |
105 | +class Poll(Activity): | |
106 | + question = models.CharField(_('Question'), max_length = 300) | |
107 | + | |
108 | + class Meta: | |
109 | + ordering = ('create_date','name') | |
110 | + verbose_name = _('Poll') | |
111 | + verbose_name_plural = _('Polls') | |
112 | + | |
113 | + def __str__(self): | |
114 | + return str(self.question) + str("/") + str(self.topic) | |
115 | + | |
116 | +class Answer(models.Model): | |
117 | + answer = models.CharField(_("Answer"), max_length = 200) | |
118 | + order = models.PositiveSmallIntegerField(_("Order")) | |
119 | + poll = models.ForeignKey(Poll, verbose_name = _('Answers'), related_name='answers') | |
120 | + | |
121 | + class Meta: | |
122 | + ordering = ('order',) | |
123 | + verbose_name = _('Answer') | |
124 | + verbose_name_plural = _('Answers') | |
125 | + | |
126 | + def __str__(self): | |
127 | + return str(self.question) + str("/") + str(self.topic) | ... | ... |
... | ... | @@ -0,0 +1,53 @@ |
1 | +{% extends "topic/index.html" %} | |
2 | + | |
3 | +{% load i18n %} | |
4 | + | |
5 | +{% block style %} | |
6 | + <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> | |
7 | +{% endblock %} | |
8 | + | |
9 | +{% block content %} | |
10 | +<div class="col-md-8 col-md-offset-2"> | |
11 | + <div class="panel panel-primary"> | |
12 | + <div class="panel-heading"> | |
13 | + <h3 class="panel-title"> | |
14 | + <span class="glyphicon glyphicon-hand-right"></span> Question?</h3> | |
15 | + </div> | |
16 | + <div class="container-fluid"> | |
17 | + <form id="form" class="" action="" method="post"> | |
18 | + <div class="row form-group"> | |
19 | + <div class="col-md-1"> | |
20 | + </br> | |
21 | + <label><span class="glyphicon glyphicon-menu-hamburger"></span></label> | |
22 | + </div> | |
23 | + <div class="col-md-10"> | |
24 | + <div class="form-control-md has-success is-empty"> | |
25 | + <input type="text" class="form-control" placeholder="Email address default size"> | |
26 | + <span class="help-block">Please enter a valid email address</span> | |
27 | + </div> | |
28 | + </div> | |
29 | + <div class="col-md-1"> | |
30 | + </br> | |
31 | + <label><span class="glyphicon glyphicon-remove" onclick="this.parentNode.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode.parentNode);"></span></label> | |
32 | + </div> | |
33 | + </div> | |
34 | + </form> | |
35 | + </br> | |
36 | + </div> | |
37 | + | |
38 | + </div> | |
39 | + <div class="panel-footer text-center"> | |
40 | + <button type="button" id="add" class="btn btn-primary btn-block btn-sm">add</button> | |
41 | + <a href="#" class="small">View Result</a> | |
42 | + </div> | |
43 | + </div> | |
44 | +<script type="text/javascript"> | |
45 | +$( "#form" ).sortable({ | |
46 | + delay: 100, | |
47 | + distance: 5, | |
48 | +}); | |
49 | +$("#add").click(function() { | |
50 | + $("#form").append('<div class="row form-group"><div class="col-md-1"></br><label><span class="glyphicon glyphicon-menu-hamburger"></span></label></div><div class="col-md-10"><div class="form-group-md has-success is-empty"><input type="text" class="form-control" placeholder="Email address default size"><span class="help-block">Please enter a valid email address</span></div></div><div class="col-md-1"></br><label><span class="glyphicon glyphicon-remove" onclick="this.parentNode.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode.parentNode);"></span></label></div></br></div>'); | |
51 | +}); | |
52 | +</script> | |
53 | +{% endblock content %} | ... | ... |
courses/urls.py
... | ... | @@ -20,5 +20,6 @@ urlpatterns = [ |
20 | 20 | url(r'^subjects/delete/(?P<slug>[\w_-]+)/$', views.DeleteSubjectView.as_view(), name='delete_subject'), |
21 | 21 | url(r'^topics/create/(?P<slug>[\w_-]+)/$', views.CreateTopicView.as_view(), name='create_topic'), |
22 | 22 | url(r'^topics/update/(?P<slug>[\w_-]+)/$', views.UpdateTopicView.as_view(), name='update_topic'), |
23 | - url(r'^topics/(?P<slug>[\w_-]+)/$', views.TopicsView.as_view(), name='view_topic') | |
23 | + url(r'^topics/(?P<slug>[\w_-]+)/$', views.TopicsView.as_view(), name='view_topic'), | |
24 | + url(r'^to/poll/to/$', views.Poll.as_view(), name='poll'), | |
24 | 25 | ] | ... | ... |
courses/views.py
... | ... | @@ -309,9 +309,7 @@ class CreateTopicView(LoginRequiredMixin, HasRoleMixin, NotificationMixin, gener |
309 | 309 | subject = get_object_or_404(Subject, slug = self.kwargs.get('slug')) |
310 | 310 | context['course'] = subject.course |
311 | 311 | context['subject'] = subject |
312 | - context['subjects'] = subject.course.subjects.filter(Q(visible=True) | Q(professors__in=[self.request.user])) | |
313 | - if (has_role(self.request.user,'system_admin')): | |
314 | - context['subjects'] = subject.course.subjects.all() | |
312 | + context['subjects'] = subject.course.subjects.all() | |
315 | 313 | return context |
316 | 314 | |
317 | 315 | def form_valid(self, form): |
... | ... | @@ -441,3 +439,26 @@ class DeleteSubjectView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): |
441 | 439 | |
442 | 440 | def get_success_url(self): |
443 | 441 | return reverse_lazy('course:view', kwargs={'slug' : self.object.course.slug}) |
442 | + | |
443 | + | |
444 | +class Poll(generic.TemplateView): | |
445 | + | |
446 | + # login_url = reverse_lazy("core:home") | |
447 | + # redirect_field_name = 'next' | |
448 | + # model = Course | |
449 | + # context_object_name = 'course' | |
450 | + template_name = 'poll/poll.html' | |
451 | + # queryset = Course.objects.all() | |
452 | + | |
453 | + # def get_queryset(self): | |
454 | + # return Course.objects.all()[0] | |
455 | + | |
456 | + def get_context_data(self, **kwargs): | |
457 | + context = super(Poll, self).get_context_data(**kwargs) | |
458 | + course = Course.objects.all()[0] | |
459 | + context['course'] = course | |
460 | + context['subject'] = course.subjects.all()[0] | |
461 | + context['subjects'] = course.subjects.all() | |
462 | + # if (has_role(self.request.user,'system_admin')): | |
463 | + # context['subjects'] = self.object.course.subjects.all() | |
464 | + return context | ... | ... |