Commit fa75a3117f41f031175d5e7414d7d9e7de214741

Authored by Zambom
1 parent 2ce54b32

Inicial template [Issue: #73]

amadeus/settings.py
@@ -47,6 +47,7 @@ INSTALLED_APPS = [ @@ -47,6 +47,7 @@ INSTALLED_APPS = [
47 'app', 47 'app',
48 'courses', 48 'courses',
49 'users', 49 'users',
  50 + 'forum',
50 ] 51 ]
51 52
52 MIDDLEWARE_CLASSES = [ 53 MIDDLEWARE_CLASSES = [
amadeus/urls.py
@@ -23,6 +23,7 @@ urlpatterns = [ @@ -23,6 +23,7 @@ urlpatterns = [
23 url(r'^home/', include('app.urls', namespace = 'app')), 23 url(r'^home/', include('app.urls', namespace = 'app')),
24 url(r'^course/', include('courses.urls', namespace = 'course')), 24 url(r'^course/', include('courses.urls', namespace = 'course')),
25 url(r'^users/', include('users.urls', namespace = 'users')), 25 url(r'^users/', include('users.urls', namespace = 'users')),
  26 + url(r'^forum/', include('forum.urls', namespace = 'forum')),
26 url(r'^admin/', admin.site.urls), 27 url(r'^admin/', admin.site.urls),
27 url(r'^', include('core.urls', namespace = 'core')), 28 url(r'^', include('core.urls', namespace = 'core')),
28 ] 29 ]
courses/templates/subject/form_view_teacher.html
1 -{% load i18n %} 1 +{% load static i18n %}
  2 +
  3 +{% block javascript %}
  4 + <script type="text/javascript">
  5 + var baseUrl = '{% url "forum:index" %}';
  6 +
  7 + function showForum(topic) {
  8 + $.ajax({
  9 + url: baseUrl,
  10 + data: {'topic': topic},
  11 + success: function(data) {
  12 + console.log(data);
  13 + $(".modal-body").html(data);
  14 + }
  15 + });
  16 +
  17 + $('#forumModal').modal();
  18 + }
  19 + </script>
  20 +{% endblock %}
2 21
3 <div class="panel panel-default"> 22 <div class="panel panel-default">
4 - <a href="{% url 'course:view_topic' topic.slug %}">  
5 - <div class="panel-heading">  
6 - <div class="row">  
7 - <div class="col-md-9 col-sm-9">  
8 - <h3>{{topic}}</h3>  
9 - </div>  
10 - <div class="col-md-3 col-sm-3">  
11 - <a href="{% url 'course:update_topic' topic.slug%}" class="btn">{% trans "edit" %}</a>  
12 - </div> 23 + <a href="{% url 'course:view_topic' topic.slug %}">
  24 + <div class="panel-heading">
  25 + <div class="row">
  26 + <div class="col-md-9 col-sm-9">
  27 + <h3>{{topic}}</h3>
  28 + </div>
  29 + <div class="col-md-3 col-sm-3">
  30 + <a href="{% url 'course:update_topic' topic.slug%}" class="btn">{% trans "edit" %}</a>
  31 + </div>
  32 + </div>
  33 + </div>
  34 + </a>
  35 + <div class="panel-body">
  36 + <p>{{topic.description|linebreaks}}</p>
  37 + <a href="javascript:showForum('{{topic.slug}}')">Forum</a>
13 </div> 38 </div>
14 - </div>  
15 - </a>  
16 - <div class="panel-body">  
17 - <p>{{topic.description|linebreaks}}</p>  
18 - </div>  
19 </div> 39 </div>
  40 +
  41 +<div class="modal fade" id="forumModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  42 + <div class="modal-dialog" role="document">
  43 + <div class="modal-content">
  44 + <div class="modal-header">
  45 + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  46 + <h4 class="modal-title" id="myModalLabel"></h4>
  47 + </div>
  48 + <div class="modal-body">
  49 +
  50 + </div>
  51 + </div>
  52 + </div>
  53 +</div>
20 \ No newline at end of file 54 \ No newline at end of file
courses/views.py
@@ -281,7 +281,7 @@ class TopicsView(LoginRequiredMixin, generic.ListView): @@ -281,7 +281,7 @@ class TopicsView(LoginRequiredMixin, generic.ListView):
281 def get_queryset(self): 281 def get_queryset(self):
282 topic = get_object_or_404(Topic, slug = self.kwargs.get('slug')) 282 topic = get_object_or_404(Topic, slug = self.kwargs.get('slug'))
283 subject = topic.subject 283 subject = topic.subject
284 - context = subject.topics.filter(visible=True) 284 + context = Topic.objects.filter(subject = subject, visible=True)
285 #if (self.request.user in subject.professors.all() or has_role(self.request.user,'system_admin')): 285 #if (self.request.user in subject.professors.all() or has_role(self.request.user,'system_admin')):
286 #context = subject.topics.all() <- Change it By Activities 286 #context = subject.topics.all() <- Change it By Activities
287 return context 287 return context
forum/models.py
@@ -13,7 +13,6 @@ It works like a &#39;topic&#39; of forum, which users can post to it and answer posts of @@ -13,7 +13,6 @@ It works like a &#39;topic&#39; of forum, which users can post to it and answer posts of
13 class Forum(Activity): 13 class Forum(Activity):
14 title = models.CharField(_('Title'), max_length = 100) 14 title = models.CharField(_('Title'), max_length = 100)
15 description = models.TextField(_('Description'), blank = True) 15 description = models.TextField(_('Description'), blank = True)
16 - create_date = models.DateTimeField(_('Create Date'), auto_now_add = True)  
17 16
18 class Meta: 17 class Meta:
19 verbose_name = _('Forum') 18 verbose_name = _('Forum')
forum/templates/forum_list.html 0 → 100644
@@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
  1 +<div class="page-header">
  2 + <h1 id="timeline">Forum</h1>
  3 + <b>Descricao: </b>Learning Python<p>
  4 + <b>Abertura: </b>Sexta-feira, 10 Junho 2016
  5 +</div>
  6 +<ul class="timeline">
  7 + <li>
  8 + <div class="timeline-badge">
  9 + <img id="logo" src="https://uxdesign-html-japm94.c9users.io/atividades-amadeus/uxdesign-html/img/topo-amadeus.png">
  10 + </div>
  11 + <p></p>
  12 + <div class="timeline-panel">
  13 + <div class="timeline-heading">
  14 + <h4 class="timeline-title">Python is insteresting</h4>
  15 + <p><small class="text-muted"><i class="glyphicon glyphicon-time"></i> 11 hours ago by </small>Carlos </p>
  16 + </div>
  17 + <div class="timeline-body">
  18 + <p>Who knows how working a String in python?</p>
  19 + </div>
  20 + <hr>
  21 + <i class="fa fa-pencil-square-o fa-2x" aria-hidden="true"></i>
  22 + </div>
  23 + </li>
  24 + <li>
  25 + <div class="timeline-badge">
  26 + <img id="logo" src="https://uxdesign-html-japm94.c9users.io/atividades-amadeus/uxdesign-html/img/topo-amadeus.png">
  27 + </div>
  28 + <p></p>
  29 + <div class="timeline-panel">
  30 + <div class="timeline-heading">
  31 + <h4 class="timeline-title">Ruby's doubt</h4>
  32 + <p><small class="text-muted"><i class="glyphicon glyphicon-time"></i> 5 hours ago by </small>Jurandi</p>
  33 + </div>
  34 + <div class="timeline-body">
  35 + <p>How works the Gems?</p>
  36 + </div>
  37 + <hr>
  38 + <i class="fa fa-pencil-square-o fa-2x" aria-hidden="true"></i>
  39 + </div>
  40 + </li>
  41 +</ul>
0 \ No newline at end of file 42 \ No newline at end of file
forum/urls.py 0 → 100644
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
  1 +from django.conf.urls import url, include
  2 +
  3 +from . import views
  4 +
  5 +
  6 +urlpatterns = [
  7 + url(r'^$', views.ForumIndex.as_view(), name='index'),
  8 +]
forum/views.py
1 -from django.shortcuts import render 1 +from django.shortcuts import render, get_object_or_404
  2 +from django.core.urlresolvers import reverse_lazy
  3 +from django.utils.translation import ugettext_lazy as _
  4 +from django.views.generic import ListView
  5 +from django.contrib.auth.mixins import LoginRequiredMixin
2 6
3 -# Create your views here. 7 +from .models import Forum
  8 +from courses.models import Topic
  9 +
  10 +class ForumIndex(LoginRequiredMixin, ListView):
  11 + login_url = reverse_lazy("core:home")
  12 + redirect_field_name = 'next'
  13 +
  14 + template_name = "forum_list.html"
  15 + context_object_name = 'forum'
  16 +
  17 + def get_queryset(self):
  18 + topic = get_object_or_404(Topic, slug = self.request.GET.get('topic', ''))
  19 +
  20 + context = Forum.objects.filter(topic = topic)
  21 +
  22 + return context