Commit c89211e5843d6d7b7e834c172febbb8299a65e67

Authored by Matheus Lins
2 parents 33ab9abf 7ca76b52

Merge branch 'master' of https://github.com/amadeusproject/amadeuslms

core/templates/base.html
@@ -7,27 +7,34 @@ @@ -7,27 +7,34 @@
7 <title>{{ title }}</title> 7 <title>{{ title }}</title>
8 8
9 <meta http-equiv="Cache-Control" content="no-cache, no-store" /> 9 <meta http-equiv="Cache-Control" content="no-cache, no-store" />
  10 + <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:300,400,500,700" type="text/css">
  11 + <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
10 12
11 -  
12 - {% block style %}  
13 - <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:300,400,500,700" type="text/css">  
14 - <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">  
15 -  
16 - <link rel="stylesheet" type="text/css" href="{% static 'bootstrap-3.3.7/css/bootstrap.min.css' %}" />  
17 - <link rel="stylesheet" type="text/css" href="{% static 'material/css/bootstrap-material-design.min.css' %}">  
18 - <link rel="stylesheet" type="text/css" href="{% static 'material/css/ripples.min.css' %}">  
19 - <link rel="stylesheet" type="text/css" href="{% static 'font-awesome-4.6.3/css/font-awesome.min.css' %}">  
20 - <link rel="stylesheet" type="text/css" href="{% static 'css/base/header.css' %}">  
21 - <link rel="stylesheet" type="text/css" href="{% static 'css/base/amadeus.css' %}">  
22 - <!--CSS block for specific-app ones -->  
23 - <link href="{% static 'img/favicon.ico' %}" rel="shortcut icon" /> 13 + <link rel="stylesheet" type="text/css" href="{% static 'bootstrap-3.3.7/css/bootstrap.min.css' %}" />
  14 + <link rel="stylesheet" type="text/css" href="{% static 'material/css/bootstrap-material-design.min.css' %}">
  15 + <link rel="stylesheet" type="text/css" href="{% static 'material/css/ripples.min.css' %}">
  16 + <link rel="stylesheet" type="text/css" href="{% static 'font-awesome-4.6.3/css/font-awesome.min.css' %}">
  17 + <link rel="stylesheet" type="text/css" href="{% static 'css/base/header.css' %}">
  18 + <link rel="stylesheet" type="text/css" href="{% static 'css/base/amadeus.css' %}">
  19 + <!--CSS block for specific-app ones -->
  20 + <link href="{% static 'img/favicon.ico' %}" rel="shortcut icon" />
24 21
25 - {% endblock %}  
26 22
27 <!-- Compiled and minified CSS --> 23 <!-- Compiled and minified CSS -->
28 - <link rel="stylesheet" type="text/css" href="{% static 'materialize/css/materialize.css' %}">  
29 - <link rel="stylesheet" type="text/css" href="{% static 'materialize/css/materialize.min.css' %}">  
30 - 24 + <link rel="stylesheet" type="text/css" href="{% static 'materialize/css/materialize.css' %}">
  25 + <link rel="stylesheet" type="text/css" href="{% static 'materialize/css/materialize.min.css' %}">
  26 +
  27 + <script type="text/javascript" src="{% static 'js/jquery-3.1.0.min.js' %}"></script>
  28 + <script type="text/javascript" src="{% static 'bootstrap-3.3.7/js/bootstrap.min.js' %}"></script>
  29 + <script src="{% static 'material/js/material.min.js' %}"></script>
  30 + <script src="{% static 'material/js/ripples.min.js' %}"></script>
  31 + <script>
  32 + $.material.init();
  33 + </script>
  34 + <script src="{% static 'js/base/header.js'%}"></script>
  35 + <!--Javascript block for specific-app ones -->
  36 + {% block style %}
  37 + {% endblock %}
31 </head> 38 </head>
32 <body> 39 <body>
33 <div class="container-fluid"> 40 <div class="container-fluid">
@@ -137,8 +144,8 @@ @@ -137,8 +144,8 @@
137 </script> 144 </script>
138 <script src="{% static 'js/base/header.js'%}"></script> 145 <script src="{% static 'js/base/header.js'%}"></script>
139 <!--Javascript block for specific-app ones --> 146 <!--Javascript block for specific-app ones -->
140 - <link rel="stylesheet" type="text/css" href="{% static 'materialize/js/materialize.css' %}">  
141 - <link rel="stylesheet" type="text/css" href="{% static 'materialize/js/materialize.min.css' %}"> 147 + <link rel="stylesheet" type="text/css" href="{% static 'materialize/js/materialize.css' %}">
  148 + <link rel="stylesheet" type="text/css" href="{% static 'materialize/js/materialize.min.css' %}">
142 149
143 {% endblock %} 150 {% endblock %}
144 </body> 151 </body>
core/templates/index.html
@@ -41,7 +41,6 @@ @@ -41,7 +41,6 @@
41 {% endif %} 41 {% endif %}
42 <div class="card"> 42 <div class="card">
43 <div class="card-block"> 43 <div class="card-block">
44 - {# <div class="row"> #}  
45 <form id="form-login" class="form-group" method="post" action=""> 44 <form id="form-login" class="form-group" method="post" action="">
46 {% csrf_token %} 45 {% csrf_token %}
47 <div class="form-group is-empty"> 46 <div class="form-group is-empty">
@@ -64,10 +63,8 @@ @@ -64,10 +63,8 @@
64 </div> 63 </div>
65 </div> 64 </div>
66 </form> 65 </form>
67 - {# </div> #}  
68 - {# <div class="row"> #}  
69 <div class="col-md-10 col-sm-10 col-xs-10 col-lg-10"> 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 </div> 68 </div>
72 {# </div> #} 69 {# </div> #}
73 {# <div class="row"> #} 70 {# <div class="row"> #}
courses/models.py
@@ -102,4 +102,26 @@ class Material(Resource): @@ -102,4 +102,26 @@ class Material(Resource):
102 topic = models.ForeignKey(Topic, verbose_name = _('Topic')) 102 topic = models.ForeignKey(Topic, verbose_name = _('Topic'))
103 student = models.ForeignKey(User, verbose_name = _('student')) 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)
courses/templates/poll/poll.html 0 → 100644
@@ -0,0 +1,53 @@ @@ -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,5 +20,6 @@ urlpatterns = [
20 url(r'^subjects/delete/(?P<slug>[\w_-]+)/$', views.DeleteSubjectView.as_view(), name='delete_subject'), 20 url(r'^subjects/delete/(?P<slug>[\w_-]+)/$', views.DeleteSubjectView.as_view(), name='delete_subject'),
21 url(r'^topics/create/(?P<slug>[\w_-]+)/$', views.CreateTopicView.as_view(), name='create_topic'), 21 url(r'^topics/create/(?P<slug>[\w_-]+)/$', views.CreateTopicView.as_view(), name='create_topic'),
22 url(r'^topics/update/(?P<slug>[\w_-]+)/$', views.UpdateTopicView.as_view(), name='update_topic'), 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
@@ -311,9 +311,7 @@ class CreateTopicView(LoginRequiredMixin, HasRoleMixin, NotificationMixin, gener @@ -311,9 +311,7 @@ class CreateTopicView(LoginRequiredMixin, HasRoleMixin, NotificationMixin, gener
311 subject = get_object_or_404(Subject, slug = self.kwargs.get('slug')) 311 subject = get_object_or_404(Subject, slug = self.kwargs.get('slug'))
312 context['course'] = subject.course 312 context['course'] = subject.course
313 context['subject'] = subject 313 context['subject'] = subject
314 - context['subjects'] = subject.course.subjects.filter(Q(visible=True) | Q(professors__in=[self.request.user]))  
315 - if (has_role(self.request.user,'system_admin')):  
316 - context['subjects'] = subject.course.subjects.all() 314 + context['subjects'] = subject.course.subjects.all()
317 return context 315 return context
318 316
319 def form_valid(self, form): 317 def form_valid(self, form):
@@ -443,3 +441,26 @@ class DeleteSubjectView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): @@ -443,3 +441,26 @@ class DeleteSubjectView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView):
443 441
444 def get_success_url(self): 442 def get_success_url(self):
445 return reverse_lazy('course:view', kwargs={'slug' : self.object.course.slug}) 443 return reverse_lazy('course:view', kwargs={'slug' : self.object.course.slug})
  444 +
  445 +
  446 +class Poll(generic.TemplateView):
  447 +
  448 + # login_url = reverse_lazy("core:home")
  449 + # redirect_field_name = 'next'
  450 + # model = Course
  451 + # context_object_name = 'course'
  452 + template_name = 'poll/poll.html'
  453 + # queryset = Course.objects.all()
  454 +
  455 + # def get_queryset(self):
  456 + # return Course.objects.all()[0]
  457 +
  458 + def get_context_data(self, **kwargs):
  459 + context = super(Poll, self).get_context_data(**kwargs)
  460 + course = Course.objects.all()[0]
  461 + context['course'] = course
  462 + context['subject'] = course.subjects.all()[0]
  463 + context['subjects'] = course.subjects.all()
  464 + # if (has_role(self.request.user,'system_admin')):
  465 + # context['subjects'] = self.object.course.subjects.all()
  466 + return context