Skip to content

Commit 3c9b7e1

Browse files
Merge pull request #1157 from scieloorg/beta
Incorporação de códigos estáveis
2 parents 9db5cbf + 4f60ab2 commit 3c9b7e1

File tree

19 files changed

+1323
-114
lines changed

19 files changed

+1323
-114
lines changed

docs/dev/rpc_spec/errno.rst

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.. _errno:
2+
3+
Números do sistema de erros
4+
===========================
5+
6+
Espaço de nomes para a representação dos diferentes tipos de erro, que podem
7+
ocorrer durante a execução das tarefas assíncronas, na estrutura retornada pela
8+
função ``getTaskResult``.
9+
10+
11+
Resumo
12+
------
13+
14+
A função ``getTaskResult`` retorna o resultado de uma tarefa assíncrona
15+
representada por uma struct contendo os campos *status* e *value*. Exceções
16+
são representadas pelo *status* ``FAILURE`` e *value* ``[errno, mensagem]``.
17+
``errno`` é um número inteiro que representa o tipo da exceção.
18+
19+
Os valores para ``errno`` são:
20+
21+
+-------+------------------+----------------------------------------------------------+
22+
| errno | Tipo | Descrição |
23+
+=======+==================+==========================================================+
24+
| 1 | DuplicationError | O artigo representado por ``xml_string`` já havia sido |
25+
| | | adicionado anteriormente |
26+
+-------+------------------+----------------------------------------------------------+
27+
| 2 | ValueError | ``xml_string`` é mal-formado ou apresenta algum problema |
28+
| | | estrutural que impeça sua identificação |
29+
+-------+------------------+----------------------------------------------------------+
30+
31+

scielomanager/editorialmanager/forms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#coding: utf-8
1+
# coding: utf-8
22

33
from django import forms
44
from . import models
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{% extends "base_lv1.html" %}
22
{% load i18n %}
33
{% load inctag_toolbars %}
4+
{% load static %}
45

56
{% block page_title %}{% trans "Journal Editorial Board" %}{% endblock %}
7+
68
{% block content %}
79

810
{% if request.user.get_profile.is_editor %}
@@ -19,91 +21,141 @@
1921
{% endblock %}
2022
{% block extrafooter %}
2123
{{ block.super }}
24+
2225
<script>
23-
$(function() {
24-
25-
function display_error(message){
26-
var template = '<div class="sys-msgs">' +
27-
'<div class="sys-msgs-wrapper">' +
28-
'<div class="alert alert-error">'+
29-
'<i class="icon-exclamation-sign"></i> ' + message +
30-
'<button class="close" data-dismiss="alert" type="button">&times;</button>' +
31-
'</div>' +
32-
'</div>'+
33-
'</div>';
34-
$('div.mainContent').prepend(template).show();
26+
27+
//Register autocomplete when model made visible to the user
28+
$('#id_modal_form').on('loaded', function(){
29+
30+
$('#id_institution').devbridgeAutocomplete({
31+
serviceUrl: "{{SETTINGS.WAYTA_URL}}{{SETTINGS.WAYTA_PATH}}institution",
32+
dataType: 'jsonp',
33+
paramName: 'q',
34+
noCache: true,
35+
params: {'accuracy': 3},
36+
minChars: 3,
37+
transformResult: function(response) {
38+
return {
39+
query:'q',
40+
suggestions: $.map(response.choices, function(dataItem) {
41+
return { value: dataItem.value, data:
42+
{'country': dataItem.country,
43+
'city': dataItem.city,
44+
'state': dataItem.state,
45+
'iso3166': dataItem.iso3166 }};
46+
})
47+
}
48+
},
49+
50+
formatResult: function (suggestion, currentValue) {
51+
return '<b>{% trans 'Institution' %}:</b> ' + suggestion.value + '</br>' +
52+
'<b>{% trans 'City' %}:</b> ' + suggestion.data.city + '</br>' +
53+
'<b>{% trans 'State' %}:</b> ' + suggestion.data.state + '</br>' +
54+
'<b>{% trans 'Country' %}:</b> ' + suggestion.data.country;
55+
},
56+
57+
onSelect: function (suggestion) {
58+
$('#id_city').val(suggestion.data.city)
59+
$('#id_state').val(suggestion.data.state)
60+
61+
$('#id_country option').each(function() {
62+
if (this.value == suggestion.data.iso3166){
63+
this.selected = this.text;
64+
$(".chzn-select").trigger("chosen:updated");
65+
}
66+
});
67+
},
68+
69+
appendTo: $('#selection')
70+
71+
});//devbridgeAutocomplete
72+
73+
});//shown
74+
75+
function display_error(message){
76+
var template = '<div class="sys-msgs">' +
77+
'<div class="sys-msgs-wrapper">' +
78+
'<div class="alert alert-error">'+
79+
'<i class="icon-exclamation-sign"></i> ' + message +
80+
'<button class="close" data-dismiss="alert" type="button">&times;</button>' +
81+
'</div>' +
82+
'</div>'+
83+
'</div>';
84+
$('div.mainContent').prepend(template).show();
85+
}
86+
87+
$('form.form_move_role').submit(function(event) {
88+
89+
{# basic validation before submittion #}
90+
var form = $(this);
91+
var f_issue_pk = form.find('.issue_pk').val();
92+
var f_board_pk = form.find('.board_pk').val();
93+
var f_role_name = form.find('.role_name').val();
94+
var f_role_position = form.find('.role_position').val();
95+
var f_direction = form.find('.direction').val();
96+
97+
var validation_results = {
98+
has_error: false,
99+
error_msg: "" {# this message is only for debug, not displayed to user #}
35100
}
36101

37-
$('form.form_move_role').submit(function(event) {
38-
{# basic validation before submittion #}
39-
var form = $(this);
40-
var f_issue_pk = form.find('.issue_pk').val();
41-
var f_board_pk = form.find('.board_pk').val();
42-
var f_role_name = form.find('.role_name').val();
43-
var f_role_position = form.find('.role_position').val();
44-
var f_direction = form.find('.direction').val();
45-
46-
var validation_results = {
47-
has_error: false,
48-
error_msg: "" {# this message is only for debug, not displayed to user #}
102+
if ($.trim(f_issue_pk) === "") {
103+
validation_results = {
104+
has_error: true,
105+
error_msg: "issue_pk field is empty"
49106
}
107+
}
50108

51-
if ($.trim(f_issue_pk) === "") {
52-
validation_results = {
53-
has_error: true,
54-
error_msg: "issue_pk field is empty"
55-
}
109+
if ($.trim(f_board_pk) === "") {
110+
validation_results = {
111+
has_error: true,
112+
error_msg: "board_pk field is empty"
56113
}
114+
}
57115

58-
if ($.trim(f_board_pk) === "") {
59-
validation_results = {
60-
has_error: true,
61-
error_msg: "board_pk field is empty"
62-
}
116+
if ($.trim(f_role_name) === "") {
117+
validation_results = {
118+
has_error: true,
119+
error_msg: "role_name field is empty"
63120
}
121+
}
64122

65-
if ($.trim(f_role_name) === "") {
66-
validation_results = {
67-
has_error: true,
68-
error_msg: "role_name field is empty"
69-
}
123+
if ($.trim(f_role_position) === "") {
124+
validation_results = {
125+
has_error: true,
126+
error_msg: "role_position field is empty"
70127
}
128+
}
71129

72-
if ($.trim(f_role_position) === "") {
73-
validation_results = {
74-
has_error: true,
75-
error_msg: "role_position field is empty"
76-
}
130+
if ($.trim(f_direction) === "") {
131+
validation_results = {
132+
has_error: true,
133+
error_msg: "direction field is empty"
77134
}
135+
}
78136

79-
if ($.trim(f_direction) === "") {
80-
validation_results = {
81-
has_error: true,
82-
error_msg: "direction field is empty"
83-
}
84-
}
85-
if (validation_results.has_error) {
137+
if (validation_results.has_error) {
86138
display_error("{% trans 'Can not move this block, please try again later' %}");
87-
console.log("validation errors when submit form", form, validation_results);
88139
return false;
89140
}
141+
90142
});
91143

92-
$('.btn-move-role').click(function(event) {
93-
event.preventDefault();
94-
var $this = $(this);
144+
$('.btn-move-role').click(function(event) {
145+
event.preventDefault();
146+
var $this = $(this);
95147

96-
if ($this.hasClass('disabled')) {
97-
return; {# disabled buttons must be ignored #}
98-
}
148+
if ($this.hasClass('disabled')) {
149+
return; {# disabled buttons must be ignored #}
150+
}
99151

100-
{# update 'direction' field, depending on which btn clicked: up or down #}
101-
var direction = $this.data('direction');
102-
var form = $this.parents('.form_move_role');
103-
form.find('.direction').val(direction);
104-
form.submit();
152+
{# update 'direction' field, depending on which btn clicked: up or down #}
153+
var direction = $this.data('direction');
154+
var form = $this.parents('.form_move_role');
155+
form.find('.direction').val(direction);
156+
form.submit();
105157

106-
});
107158
});
159+
108160
</script>
109161
{% endblock %}

scielomanager/editorialmanager/templates/board/board_list_data.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ <h5>{% trans "Actions" %}:</h5>
6565
</li>
6666
{% endif %}
6767
<li>
68-
<a href="{% url editorial.export.csv.issue journal.id issue.id %}" class="tip-right" data-original-title="{% trans 'Download full list as CSV file.' %}">
69-
<i class="icon-download-alt"></i> {% trans "Export csv " %}
68+
<a href="{% url editorial.export.csv.issue journal.id issue.id %}">
69+
<i class="icon-download-alt"></i> {% trans "Download this board as CSV file" %}
7070
</a>
7171
</li>
7272

scielomanager/editorialmanager/templates/board/board_member_edit_form.html

+35-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,39 @@
22

33
<form id="member-form" action="{{ post_url|default:'' }}" method="POST" class="form-horizontal">
44
{% csrf_token %}
5-
{% for field in form %}
6-
{% show_field field %}
7-
{% endfor %}
5+
6+
{% show_field form.role %}
7+
{% show_field form.first_name %}
8+
{% show_field form.last_name %}
9+
{% show_field form.email %}
10+
<div class="control-group {% if form.institution.errors %}error{% endif %}">
11+
<label for="{{ form.institution.auto_id }}" class="{% if form.institution.field.required %} req-field {% endif %} control-label">
12+
13+
{% trans form.institution.label %}
14+
15+
{% if form.institution.help_text %}
16+
<i rel="popover" data-toggle="popover" data-trigger="hover" data-content="{{ form.institution.help_text }}" class="icon-question-sign"></i>
17+
{% endif %}
18+
19+
</label>
20+
<div class="controls">
21+
22+
{{ form.institution }}
23+
24+
<div id="selection"></div>
25+
26+
{% if form.institution.errors %}
27+
<div class="alert alert-error">
28+
{{ form.institution.errors }}
29+
</div>
30+
{% endif %}
31+
32+
</div>
33+
</div>
34+
{% show_field form.link_cv %}
35+
{% show_field form.city %}
36+
{% show_field form.state %}
37+
{% show_field form.country %}
38+
{% show_field form.research_id %}
39+
{% show_field form.orcid %}
840
</form>

scielomanager/editorialmanager/templates/includes/journal_detail_info.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h4>{{ journal.title }}</h4>
2121
<strong>{{ journal.collections.all|join:', ' }}</strong>
2222
</li>
2323
<li class="pull-right">
24-
<a href="{% url editorial.export.csv.journal journal.id %}" class="tip-bottom" data-original-title="{% trans 'Download full list as CSV file.' %}"> Download as CSV <i class="icon-download-alt"></i></a>
24+
<a href="{% url editorial.export.csv.journal journal.id %}"> Download full board as CSV file <i class="icon-download-alt"></i></a>
2525
</li>
2626
</ul>
2727
{% modal 'Journal Details' %}

scielomanager/editorialmanager/templatetags/modal.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
#coding: utf-8
1+
# coding: utf-8
22
from django import template
33

44
register = template.Library()
55

6+
67
@register.inclusion_tag('modal.html')
78
def modal(title):
89
"""
910
Return a modal bootstrap html
1011
"""
1112
return {'title': title}
1213

14+
1315
@register.inclusion_tag('modal_form.html')
1416
def modal_form(title='', modal_id='id_modal_form', form_tag_id='id_modal_form_tag'):
1517
"""
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#coding: utf-8
1+
# coding: utf-8
22
from django import template
33

44
register = template.Library()
55

6+
67
@register.inclusion_tag('inctag/field.html')
78
def show_field(field):
89
return {'field': field}

scielomanager/editorialmanager/tests/test_pages.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,13 @@ def test_authenticated_users_can_access(self):
440440
reverse('editorial.export.csv.issue', args=[self.journal.id, self.issue.id]),
441441
user=self.user
442442
)
443-
443+
journal_slug = slugify(self.journal.title)
444+
issue_year = self.issue.publication_year
445+
issue_volume = self.issue.volume
446+
issue_number = self.issue.number
447+
filename = u'board_%s_%s_v%s_n%s' % (journal_slug, issue_year, issue_volume, issue_number)
444448
self.assertEquals(response.content_disposition,
445-
'attachment; filename="edboard-%s.csv"' % slugify(self.journal.title))
449+
'attachment; filename="%s.csv"' % filename)
446450

447451
def test_authenticated_users_download_content(self):
448452

0 commit comments

Comments
 (0)