Commit 499cab49f9c3abbe41f3f5325c162304368464ff

Authored by Zambom
1 parent 66b9ac80

Adjusting error in bulletin view

bulletin/templates/bulletin/view.html
@@ -4,148 +4,148 @@ @@ -4,148 +4,148 @@
4 {% load django_bootstrap_breadcrumbs %} 4 {% load django_bootstrap_breadcrumbs %}
5 5
6 {% block javascript%} 6 {% block javascript%}
7 - {{ block.super }} 7 + {{ block.super }}
8 {% endblock%} 8 {% endblock%}
9 9
10 {% block breadcrumbs %} 10 {% block breadcrumbs %}
11 - {{ block.super }}  
12 - {% breadcrumb topic 'subjects:topic_view' subject.slug topic.slug %}  
13 - {% breadcrumb bulletin 'bulletin:view' bulletin.slug %} 11 + {{ block.super }}
  12 + {% breadcrumb topic 'subjects:topic_view' subject.slug topic.slug %}
  13 + {% breadcrumb bulletin 'bulletin:view' bulletin.slug %}
14 {% endblock %} 14 {% endblock %}
15 15
16 {% block content %} 16 {% block content %}
17 - {% if messages %}  
18 - {% for message in messages %}  
19 - <div class="alert alert-{{ message.tags }} alert-dismissible" role="alert">  
20 - <button type="button" class="close" data-dismiss="alert" aria-label="Close">  
21 - <span aria-hidden="true">&times;</span>  
22 - </button>  
23 - <p>{{ message }}</p>  
24 - </div>  
25 - {% endfor %}  
26 - {% endif %}  
27 -  
28 - {% resource_permissions request.user bulletin as has_resource_permissions %}  
29 -  
30 - {% if bulletin.visible %} 17 + {% if messages %}
  18 + {% for message in messages %}
  19 + <div class="alert alert-{{ message.tags }} alert-dismissible" role="alert">
  20 + <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  21 + <span aria-hidden="true">&times;</span>
  22 + </button>
  23 + <p>{{ message }}</p>
  24 + </div>
  25 + {% endfor %}
  26 + {% endif %}
  27 +
  28 + {% resource_permissions request.user bulletin as has_resource_permissions %}
  29 +
  30 + {% if bulletin.visible %}
31 <div class="panel panel-info topic-panel"> 31 <div class="panel panel-info topic-panel">
32 - <div class="panel-heading"> 32 + <div class="panel-heading">
33 {% elif has_resource_permissions %} 33 {% elif has_resource_permissions %}
34 <div class="panel panel-info topic-panel-invisible"> 34 <div class="panel panel-info topic-panel-invisible">
35 - <div class="panel-heading panel-invisible">  
36 - {% endif %}  
37 - <div class="row">  
38 - <div class="col-md-12 category-header">  
39 - <h4 class="panel-title" style="margin-top: 10px; margin-bottom: 8px">  
40 - <span>{{ bulletin }}</span>  
41 - </h4>  
42 -  
43 - <div class="col-md-5 pull-right category-card-items">  
44 - <a href="{% url 'mural:resource_view' bulletin.slug %}" class="pull-right action_icon">  
45 - <i class="fa fa-list" aria-hidden="true"></i>  
46 - {% resource_mural_number bulletin request.user %}  
47 - </a>  
48 - </div>  
49 - </div>  
50 - </div>  
51 - </div>  
52 - <div id="{{subject.slug}}" class="panel-collapse in collapse category-panel-content">  
53 - {% autoescape off %}  
54 - {{ bulletin.content }}  
55 - {% endautoescape %}  
56 -  
57 - <hr />  
58 -  
59 - <div class="row">  
60 - <div class="col-md-12">  
61 - <b><h5> {% trans "Check your goals" %}:</b></h5>  
62 - <table class="table table-bordered">  
63 - <thead>  
64 - <tr>  
65 - <th style="text-align:center;vertical-align:middle" colspan="1" rowspan="2">Meta</th>  
66 - <th style="text-align:center;vertical-align:middle" colspan="1" rowspan="2">Média da Turma</th>  
67 - <th style="text-align:center" colspan="3">Dados Individuais</th>  
68 - </tr>  
69 - <tr>  
70 - <th style="text-align:center">Desejada</th>  
71 - <th style="text-align:center">Estabelecida</th>  
72 - <th style="text-align:center">Alcançada</th>  
73 - </tr>  
74 - </thead>  
75 - <tbody>  
76 - {% for meta in metas%}  
77 - <tr>  
78 - <td>{{ meta.description }}</td>  
79 - <td style="text-align:center">{{ meta.media }}%</td>  
80 - <td style="text-align:center">{{ meta.desejada }} %</td>  
81 - <td style="text-align:center">{{ meta.estabelecida }} %</td>  
82 -  
83 - <!-- Cor amarela -->  
84 - {% if meta.alcancada < meta.desejada and meta.alcancada > meta.estabelecida %}  
85 - <td style="text-align:center;background-color:#f3ff00">{{ meta.alcancada }}%</td>  
86 - {% endif %}  
87 -  
88 - {% if meta.alcancada > meta.desejada and meta.alcancada < meta.estabelecida %}  
89 - <td style="text-align:center;background-color:#f3ff00">{{ meta.alcancada }}%</td>  
90 -  
91 - {% endif %}  
92 - <!-- Cor amarela -->  
93 -  
94 -  
95 - <!-- Cor verde -->  
96 - {% if meta.alcancada > meta.desejada and meta.alcancada > meta.estabelecida %}  
97 - <td style="text-align:center;background-color:#7bdc42">{{ meta.alcancada }}%</td>  
98 - {% endif %}  
99 - <!-- Cor verde -->  
100 -  
101 - <!-- Cor vermelha -->  
102 - {% if meta.alcancada < meta.desejada and meta.alcancada < meta.estabelecida %}  
103 - <td style="text-align:center;background-color:#ff0000">{{ meta.alcancada }}%</td>  
104 -  
105 - {% endif %}  
106 - <!-- Cor vermelha -->  
107 -  
108 - </tr>  
109 -  
110 - {% endfor %}  
111 - </tbody>  
112 - </table>  
113 - </div>  
114 - </div>  
115 -  
116 - <div class="row">  
117 - <div class="col-md-8 col-md-offset-2 alert-warning bulletin-warning">  
118 - <div class="col-md-2">  
119 - <img src="{% static 'img/warning.png' %}" class="img-responsive" />  
120 - </div>  
121 - <div class="col-md-10 col-sm-10">  
122 - <h4>{% trans 'There are obstructions to your activities?' %}</h4>  
123 - <p><a data-toggle="modal" data-target="#bulletin-difficulties-modal" href="">{% trans 'Click here' %}</a> {% trans 'to communicate the difficulties that may decrease your performance.' %}</p>  
124 - </div>  
125 - </div>  
126 - </div>  
127 - </div>  
128 - </div>  
129 -  
130 - <div class="modal fade" tabindex="-1" role="dialog" id="bulletin-difficulties-modal">  
131 - <div class="modal-dialog" role="document">  
132 - <div class="modal-content">  
133 - <div class="modal-header">  
134 - <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>  
135 - <h4 class="modal-title">{% trans 'Inform difficulties' %}</h4>  
136 - </div>  
137 - <div class="modal-body">  
138 - <form id="bulletin-difficulties" action="" method="POST" enctype="multipart/form-data">  
139 - {% csrf_token %}  
140 -  
141 - <textarea class="form-control" id="dificulties" name="difficulties" placeholder="{% trans 'Type here the dificulties that may harm your performance' %}"></textarea>  
142 - </form>  
143 - </div>  
144 - <div class="modal-footer">  
145 - <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans "Close" %}</button>  
146 - <button type="submit" class="btn btn-success btn-raised erase-button" form="bulletin-difficulties">{% trans "Send" %}</button>  
147 - </div>  
148 - </div>  
149 - </div>  
150 - </div> 35 + <div class="panel-heading panel-invisible">
  36 + {% endif %}
  37 + <div class="row">
  38 + <div class="col-md-12 category-header">
  39 + <h4 class="panel-title" style="margin-top: 10px; margin-bottom: 8px">
  40 + <span>{{ bulletin }}</span>
  41 + </h4>
  42 +
  43 + <div class="col-md-5 pull-right category-card-items">
  44 + <a href="{% url 'mural:resource_view' bulletin.slug %}" class="pull-right action_icon">
  45 + <i class="fa fa-list" aria-hidden="true"></i>
  46 + {% resource_mural_number bulletin request.user %}
  47 + </a>
  48 + </div>
  49 + </div>
  50 + </div>
  51 + </div>
  52 + <div id="{{subject.slug}}" class="panel-collapse in collapse category-panel-content">
  53 + {% autoescape off %}
  54 + {{ bulletin.content }}
  55 + {% endautoescape %}
  56 +
  57 + <hr />
  58 +
  59 + <div class="row">
  60 + <div class="col-md-12">
  61 + <b><h5> {% trans "Check your goals" %}:</b></h5>
  62 + <table class="table table-bordered">
  63 + <thead>
  64 + <tr>
  65 + <th style="text-align:center;vertical-align:middle" colspan="1" rowspan="2">Meta</th>
  66 + <th style="text-align:center;vertical-align:middle" colspan="1" rowspan="2">Média da Turma</th>
  67 + <th style="text-align:center" colspan="3">Dados Individuais</th>
  68 + </tr>
  69 + <tr>
  70 + <th style="text-align:center">Desejada</th>
  71 + <th style="text-align:center">Estabelecida</th>
  72 + <th style="text-align:center">Alcançada</th>
  73 + </tr>
  74 + </thead>
  75 + <tbody>
  76 + {% for meta in metas%}
  77 + <tr>
  78 + <td>{{ meta.description }}</td>
  79 + <td style="text-align:center">{{ meta.media }}%</td>
  80 + <td style="text-align:center">{{ meta.desejada }} %</td>
  81 + <td style="text-align:center">{{ meta.estabelecida }} %</td>
  82 +
  83 + <!-- Cor amarela -->
  84 + {% if meta.alcancada < meta.desejada and meta.alcancada > meta.estabelecida %}
  85 + <td style="text-align:center;background-color:#f3ff00">{{ meta.alcancada }}%</td>
  86 + {% endif %}
  87 +
  88 + {% if meta.alcancada > meta.desejada and meta.alcancada < meta.estabelecida %}
  89 + <td style="text-align:center;background-color:#f3ff00">{{ meta.alcancada }}%</td>
  90 +
  91 + {% endif %}
  92 + <!-- Cor amarela -->
  93 +
  94 +
  95 + <!-- Cor verde -->
  96 + {% if meta.alcancada > meta.desejada and meta.alcancada > meta.estabelecida %}
  97 + <td style="text-align:center;background-color:#7bdc42">{{ meta.alcancada }}%</td>
  98 + {% endif %}
  99 + <!-- Cor verde -->
  100 +
  101 + <!-- Cor vermelha -->
  102 + {% if meta.alcancada < meta.desejada and meta.alcancada < meta.estabelecida %}
  103 + <td style="text-align:center;background-color:#ff0000">{{ meta.alcancada }}%</td>
  104 +
  105 + {% endif %}
  106 + <!-- Cor vermelha -->
  107 +
  108 + </tr>
  109 +
  110 + {% endfor %}
  111 + </tbody>
  112 + </table>
  113 + </div>
  114 + </div>
  115 +
  116 + <div class="row">
  117 + <div class="col-md-8 col-md-offset-2 alert-warning bulletin-warning">
  118 + <div class="col-md-2">
  119 + <img src="{% static 'img/warning.png' %}" class="img-responsive" />
  120 + </div>
  121 + <div class="col-md-10 col-sm-10">
  122 + <h4>{% trans 'There are obstructions to your activities?' %}</h4>
  123 + <p><a data-toggle="modal" data-target="#bulletin-difficulties-modal" href="">{% trans 'Click here' %}</a> {% trans 'to communicate the difficulties that may decrease your performance.' %}</p>
  124 + </div>
  125 + </div>
  126 + </div>
  127 + </div>
  128 + </div>
  129 +
  130 + <div class="modal fade" tabindex="-1" role="dialog" id="bulletin-difficulties-modal">
  131 + <div class="modal-dialog" role="document">
  132 + <div class="modal-content">
  133 + <div class="modal-header">
  134 + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  135 + <h4 class="modal-title">{% trans 'Inform difficulties' %}</h4>
  136 + </div>
  137 + <div class="modal-body">
  138 + <form id="bulletin-difficulties" action="" method="POST" enctype="multipart/form-data">
  139 + {% csrf_token %}
  140 +
  141 + <textarea class="form-control" id="dificulties" name="difficulties" placeholder="{% trans 'Type here the dificulties that may harm your performance' %}"></textarea>
  142 + </form>
  143 + </div>
  144 + <div class="modal-footer">
  145 + <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans "Close" %}</button>
  146 + <button type="submit" class="btn btn-success btn-raised erase-button" form="bulletin-difficulties">{% trans "Send" %}</button>
  147 + </div>
  148 + </div>
  149 + </div>
  150 + </div>
151 {% endblock %} 151 {% endblock %}
bulletin/templates/bulletin/window_view.html
@@ -98,15 +98,15 @@ @@ -98,15 +98,15 @@
98 </div> 98 </div>
99 99
100 <div class="row"> 100 <div class="row">
101 - <div class="col-md-8 col-md-offset-2 alert-warning bulletin-warning">  
102 - <div class="col-md-2">  
103 - <img src="{% static 'img/warning.png' %}" class="img-responsive" />  
104 - </div>  
105 - <div class="col-md-10 col-sm-10">  
106 - <h4>{% trans 'There are obstructions to your activities?' %}</h4>  
107 - <p><a data-toggle="modal" data-target="#bulletin-difficulties-modal" href="">{% trans 'Click here' %}</a> {% trans 'to communicate the difficulties that may decrease your performance.' %}</p>  
108 - </div> 101 + <div class="col-md-8 col-md-offset-2 alert-warning bulletin-warning">
  102 + <div class="col-md-2">
  103 + <img src="{% static 'img/warning.png' %}" class="img-responsive" />
  104 + </div>
  105 + <div class="col-md-10 col-sm-10">
  106 + <h4>{% trans 'There are obstructions to your activities?' %}</h4>
  107 + <p><a data-toggle="modal" data-target="#bulletin-difficulties-modal" href="">{% trans 'Click here' %}</a> {% trans 'to communicate the difficulties that may decrease your performance.' %}</p>
109 </div> 108 </div>
  109 + </div>
110 </div> 110 </div>
111 </div> 111 </div>
112 <div class="modal fade" tabindex="-1" role="dialog" id="bulletin-difficulties-modal"> 112 <div class="modal fade" tabindex="-1" role="dialog" id="bulletin-difficulties-modal">
bulletin/views.py
@@ -416,24 +416,26 @@ def create_excel_file(estudantes,metas,meta): @@ -416,24 +416,26 @@ def create_excel_file(estudantes,metas,meta):
416 for m in metas: 416 for m in metas:
417 worksheet.write(0,count_meta,u'%s' % (m.description) ) 417 worksheet.write(0,count_meta,u'%s' % (m.description) )
418 count_meta += 1 418 count_meta += 1
  419 +
419 for estudante in estudantes: 420 for estudante in estudantes:
420 worksheet.write(contador_estudante,0,estudante.id ) 421 worksheet.write(contador_estudante,0,estudante.id )
421 - if estudante.social_name:  
422 - worksheet.write(contador_estudante,1,estudante.social_name)  
423 - else:  
424 - nome = estudante.username + " " + estudante.last_name  
425 - worksheet.write(contador_estudante,1,nome) 422 +
  423 + nome = str(estudante)
  424 + worksheet.write(contador_estudante,1,nome)
426 425
427 contador_estudante += 1 426 contador_estudante += 1
  427 +
428 path1 = os.path.join(settings.BASE_DIR,'bulletin') 428 path1 = os.path.join(settings.BASE_DIR,'bulletin')
429 path2 = os.path.join(path1,'static') 429 path2 = os.path.join(path1,'static')
430 path3 = os.path.join(path2,'xls') 430 path3 = os.path.join(path2,'xls')
431 431
432 nome = str(meta.slug) + ".xls" 432 nome = str(meta.slug) + ".xls"
433 folder_path = join(path3, nome) 433 folder_path = join(path3, nome)
  434 +
434 #check if the folder already exists 435 #check if the folder already exists
435 if not os.path.isdir(path3): 436 if not os.path.isdir(path3):
436 os.makedirs(path3) 437 os.makedirs(path3)
  438 +
437 workbook.save(folder_path) 439 workbook.save(folder_path)
438 440
439 def read_excel_file(estudante,meta,qtd,boletim): 441 def read_excel_file(estudante,meta,qtd,boletim):
@@ -442,19 +444,21 @@ def read_excel_file(estudante,meta,qtd,boletim): @@ -442,19 +444,21 @@ def read_excel_file(estudante,meta,qtd,boletim):
442 planilha = arquivo.sheet_by_index(0) 444 planilha = arquivo.sheet_by_index(0)
443 alcance = [] 445 alcance = []
444 medias = [] 446 medias = []
  447 + soma = 0
445 448
446 for n in range(planilha.nrows): 449 for n in range(planilha.nrows):
447 if n == 0: 450 if n == 0:
448 continue 451 continue
449 else: 452 else:
450 linha = planilha.row_values(n) 453 linha = planilha.row_values(n)
451 - if int(linha[0]) == int(estudante.id):  
452 - for x in range(2,2+qtd):  
453 - alcance.append(int(linha[x]))  
454 - break 454 +
  455 + for x in range(2,2+qtd):
  456 + alcance.append(int(linha[x]))
455 457
456 for b in range(2,planilha.ncols): 458 for b in range(2,planilha.ncols):
457 - soma = sum(list(planilha.col_values(b,1,planilha.nrows))) 459 + for item in planilha.col_values(b,1,planilha.nrows):
  460 + soma += int(item)
  461 +
458 media = soma // (planilha.nrows - 1) 462 media = soma // (planilha.nrows - 1)
459 medias.append(media) 463 medias.append(media)
460 464