Skip to content

Commit e28d758

Browse files
committed
Merge pull request #1114 from scieloorg/beta
Incorporação de códigos estáveis.
2 parents c99c877 + a31ec12 commit e28d758

File tree

8 files changed

+42
-60
lines changed

8 files changed

+42
-60
lines changed

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ clean:
1111
@echo "Removing all .pyc files..."
1212
@find . -name "*.pyc" -delete
1313
@echo "Removing articletrack db structure..."
14-
@python $(APP_PATH)/clear_articletrack_contenttypes.py 2> /tmp/clear_articletrack_contenttypes.out
1514

1615
test:
1716
@python $(MANAGE) test --settings=$(SETTINGS_TEST)

scielomanager/clear_articletrack_contenttypes.py

-34
This file was deleted.

scielomanager/drop_articletrack_tables.sql

-15
This file was deleted.

scielomanager/editorialmanager/tests/modelfactories.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class EditorialMemberFactory(factory.Factory):
3232
role = factory.SubFactory(RoleTypeFactory)
3333
board = factory.SubFactory(EditorialBoardFactory)
3434

35-
#Required fields
35+
# Required fields
3636
first_name = factory.Sequence(lambda n: "first_name_%s" % n)
3737
last_name = factory.Sequence(lambda n: "last_name_%s" % n)
3838
email = factory.Sequence(lambda n: "email%[email protected]" % n)

scielomanager/editorialmanager/tests/test_forms.py

+29-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
from journalmanager.tests import modelfactories
99

1010
from . import modelfactories as editorial_modelfactories
11-
from editorialmanager.models import EditorialMember, EditorialBoard, RoleType, RoleTypeTranslation
11+
from editorialmanager.models import (EditorialMember,
12+
EditorialBoard,
13+
RoleType,
14+
RoleTypeTranslation)
1215
from audit_log.models import AuditLogEntry, ADDITION, CHANGE, DELETION
1316

1417

@@ -64,7 +67,7 @@ def test_editor_edit_journal_with_valid_formdata(self):
6467
of the list.
6568
6669
In order to take this action, the user needs be part of this group:
67-
``superuser`` or ``editors`` or ``librarian``
70+
``superuser`` or ``editors`` or ``librarian`` or ``trainee``
6871
"""
6972

7073
use_license = modelfactories.UseLicenseFactory.create()
@@ -129,7 +132,7 @@ def test_add_user_as_editor_formdata(self):
129132
the editor area and journal have a new editor of the journal
130133
131134
In order to take this action, the user needs be part of this group:
132-
``superuser`` or ``librarian``
135+
``superuser`` or ``librarian`` or ``trainee``
133136
"""
134137

135138
group = modelfactories.GroupFactory(name="Editors")
@@ -505,8 +508,9 @@ def test_DELETE_board_member_valid_POST_is_valid(self):
505508

506509
class EditorialMemberFormAsLibrarianTests(EditorialMemberFormAsEditorTests):
507510
"""
508-
Excecute the same tests that an Editors (EditorialMemberFormAsEditorTests), the setUp is almost the same.
509-
Only change is that the self.user is assigned as a member of "Librarian" group instead of "Editors" group.
511+
Excecute the same tests that an Editors (EditorialMemberFormAsEditorTests),
512+
the setUp is almost the same.Only change is that the self.user is assigned
513+
as a member of "Librarian" group instead of "Editors" group.
510514
"""
511515
def setUp(self):
512516
super(EditorialMemberFormAsLibrarianTests, self).setUp()
@@ -522,6 +526,26 @@ def tearDown(self):
522526
super(EditorialMemberFormAsLibrarianTests, self).tearDown()
523527

524528

529+
class EditorialMemberFormAsTraineeTests(EditorialMemberFormAsEditorTests):
530+
"""
531+
Excecute the same tests that an Editors (EditorialMemberFormAsEditorTests),
532+
the setUp is almost the same. Only change is that the self.user is assigned
533+
as a member of "Trainee" group instead of "Editors" group.
534+
"""
535+
def setUp(self):
536+
super(EditorialMemberFormAsTraineeTests, self).setUp()
537+
# change user group to belong to Trainee group
538+
self.user.groups.clear()
539+
group = modelfactories.GroupFactory(name="Trainee")
540+
self.user.groups.add(group)
541+
self.user.save()
542+
543+
_add_required_permission_to_group(group)
544+
545+
def tearDown(self):
546+
super(EditorialMemberFormAsTraineeTests, self).tearDown()
547+
548+
525549
class MembersSortingOnActionTests(WebTest):
526550

527551
def setUp(self):

scielomanager/editorialmanager/views.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,14 @@ def _do_move_board_block(board_pk, position, direction):
155155

156156

157157
def _user_has_access(user):
158-
return user.is_superuser or user.get_profile().is_editor or user.get_profile().is_librarian
158+
return user.is_superuser or user.get_profile().is_editor or user.get_profile().is_librarian or user.get_profile().is_trainee
159159

160160

161161
def _get_journals_by_user_access(user):
162162
user_profile = user.get_profile()
163163
if user_profile.is_editor:
164164
journals = Journal.userobjects.active().filter(editor=user)
165-
elif user_profile.is_librarian or user.is_superuser:
165+
elif user_profile.is_librarian or user.is_superuser or user_profile.is_trainee:
166166
journals = Journal.userobjects.active()
167167
else:
168168
journals = []
@@ -236,7 +236,11 @@ def edit_journal(request, journal_id):
236236
helpers.log_change(**audit_data)
237237

238238
messages.success(request, _('Journal updated successfully.'))
239-
return HttpResponseRedirect(reverse('editorial.index'))
239+
240+
if request.user.get_profile().is_editor:
241+
return HttpResponseRedirect(reverse('editorial.index'))
242+
else:
243+
return HttpResponseRedirect(reverse('journal.dash', args=[journal.id]))
240244
else:
241245
messages.error(request, _('Check mandatory fields.'))
242246

scielomanager/journalmanager/models.py

+4
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ def is_editor(self):
319319
def is_librarian(self):
320320
return self.user.groups.filter(name__iexact='Librarian').exists()
321321

322+
@property
323+
def is_trainee(self):
324+
return self.user.groups.filter(name__iexact='Trainee').exists()
325+
322326
@property
323327
def gravatar_id(self):
324328
return hashlib.md5(self.user.email.lower().strip()).hexdigest()

scielomanager/journalmanager/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#coding: utf-8
1+
# coding: utf-8
22
import json
33
import urlparse
44
from datetime import datetime

0 commit comments

Comments
 (0)