diff --git a/alembic/versions/2dcee6dfae9d_create_profile_table.py b/alembic/versions/2dcee6dfae9d_create_profile_table.py new file mode 100644 index 0000000..38d0a10 --- /dev/null +++ b/alembic/versions/2dcee6dfae9d_create_profile_table.py @@ -0,0 +1,48 @@ +"""create profile table + +Revision ID: 2dcee6dfae9d +Revises: 4f12d8650050 +Create Date: 2016-05-24 14:30:22.687206 + +""" + +# revision identifiers, used by Alembic. +revision = '2dcee6dfae9d' +down_revision = '4f12d8650050' + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects.postgresql import ARRAY +import datetime + + +def make_timestamp(): + now = datetime.datetime.utcnow() + return now.isoformat() + + +def upgrade(): + op.create_table( + 'profile', + sa.Column('id', sa.Integer, primary_key=True), + sa.Column('name', sa.Text, nullable=False, unique=True), + sa.Column('description', sa.Text, nullable=False), + sa.Column('access', ARRAY(sa.Text), nullable=False), + sa.Column('created', sa.Text, server_default=make_timestamp()), + ) + + # Add two categories + query = 'INSERT INTO profile (name, description, access) VALUES (\'Colaborador\', \'Colaborador geral\', \'{wikilibras}\')' + op.execute(query) + query = 'INSERT INTO profile (name, description, access) VALUES (\'Animador\', \'Animador 3D\', \'{wikilibras, corretor_sinais}\')' + op.execute(query) + query = 'INSERT INTO profile (name, description, access) VALUES (\'Especialista\', \'Especialista em LIBRAS\', \'{wikilibras, validador_sinais}\')' + op.execute(query) + + op.add_column('user', sa.Column('profile_id', sa.Integer, sa.ForeignKey('profile.id'), server_default="1")) + + +def downgrade(): + op.drop_column('user', 'profile_id') + op.drop_table('profile') + \ No newline at end of file diff --git a/pybossa/forms/forms.py b/pybossa/forms/forms.py index 19f2760..c948ba0 100644 --- a/pybossa/forms/forms.py +++ b/pybossa/forms/forms.py @@ -279,7 +279,11 @@ class RegisterForm(Form): [validators.Required(err_msg), validators.EqualTo('confirm', err_msg_2)]) - confirm = PasswordField(lazy_gettext('Repeat Password')) + confirm = PasswordField(lazy_gettext('Repeat Password')) + profile = SelectField(lazy_gettext('You want to participate as')) + + def set_profile_choices(self, choices): + self.profile.choices = choices class UpdateProfileForm(Form): diff --git a/pybossa/model/profile.py b/pybossa/model/profile.py new file mode 100644 index 0000000..1051674 --- /dev/null +++ b/pybossa/model/profile.py @@ -0,0 +1,41 @@ +# -*- coding: utf8 -*- +# This file is part of PyBossa. +# +# Copyright (C) 2015 SciFabric LTD. +# +# PyBossa is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# PyBossa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with PyBossa. If not, see . + +from sqlalchemy import Integer, Text +from sqlalchemy.schema import Column, ForeignKey +from sqlalchemy.dialects.postgresql import ARRAY + +from pybossa.core import db +from pybossa.model import DomainObject, make_timestamp + + +class Profile(db.Model, DomainObject): + '''A Table with Profiles for Users.''' + + __tablename__ = 'profile' + + #: Category ID + id = Column(Integer, primary_key=True) + #: Name of the Profile + name = Column(Text, nullable=False, unique=True) + #: Description of the Profile + description = Column(Text, nullable=False) + #: Set of allowed projects for the profile + access = Column(ARRAY(Text), nullable=False) + #: UTC timestamp when the Category was created + created = Column(Text, default=make_timestamp) diff --git a/pybossa/model/user.py b/pybossa/model/user.py index 4d0c32c..14a2e94 100644 --- a/pybossa/model/user.py +++ b/pybossa/model/user.py @@ -61,11 +61,13 @@ class User(db.Model, DomainObject, UserMixin): confirmation_email_sent = Column(Boolean, default=False) subscribed = Column(Boolean, default=True) info = Column(MutableDict.as_mutable(JSON), default=dict()) - + profile_id = Column(Integer, ForeignKey('profile.id')) + ## Relationships task_runs = relationship(TaskRun, backref='user') projects = relationship(Project, backref='owner') blogposts = relationship(Blogpost, backref='owner') + profile = relationship("Profile") def get_id(self): diff --git a/pybossa/repositories/user_repository.py b/pybossa/repositories/user_repository.py index 29764f0..0ef7f74 100644 --- a/pybossa/repositories/user_repository.py +++ b/pybossa/repositories/user_repository.py @@ -20,6 +20,7 @@ from sqlalchemy import or_, func from sqlalchemy.exc import IntegrityError from pybossa.model.user import User +from pybossa.model.profile import Profile from pybossa.exc import WrongObjectError, DBIntegrityError @@ -86,3 +87,17 @@ class UserRepository(object): name = user.__class__.__name__ msg = '%s cannot be %s by %s' % (name, action, self.__class__.__name__) raise WrongObjectError(msg) + + # Methods for Profile objects + def get_profile(self, id=None): + if id is None: + return self.db.session.query(Profile).first() + return self.db.session.query(Profile).get(id) + + def get_profile_by(self, **attributes): + return self.db.session.query(Profile).filter_by(**attributes).first() + + def profile_has_access(self, user, project_name): + profile = self.get_profile(user.profile_id) + return user.admin or project_name in profile.access + diff --git a/pybossa/themes/default/templates/account/register.html b/pybossa/themes/default/templates/account/register.html index d8ab36f..8c6ffce 100644 --- a/pybossa/themes/default/templates/account/register.html +++ b/pybossa/themes/default/templates/account/register.html @@ -20,6 +20,7 @@ {{ render_field(form.email_addr, placeholder= _('hello@mywebsite.org')) }} {{ render_field(form.password, placeholder= _('my secret password')) }} {{ render_field(form.confirm, placeholder= _('my secret password')) }} + {{ render_field(form.profile) }}
diff --git a/pybossa/themes/default/translations/pt_BR/LC_MESSAGES/messages.mo b/pybossa/themes/default/translations/pt_BR/LC_MESSAGES/messages.mo index 21a1650..5c69774 100644 Binary files a/pybossa/themes/default/translations/pt_BR/LC_MESSAGES/messages.mo and b/pybossa/themes/default/translations/pt_BR/LC_MESSAGES/messages.mo differ diff --git a/pybossa/themes/default/translations/pt_BR/LC_MESSAGES/messages.po b/pybossa/themes/default/translations/pt_BR/LC_MESSAGES/messages.po index f041bf7..05bde08 100644 --- a/pybossa/themes/default/translations/pt_BR/LC_MESSAGES/messages.po +++ b/pybossa/themes/default/translations/pt_BR/LC_MESSAGES/messages.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "POT-Creation-Date: 2015-08-20 13:26-0300\n" -"PO-Revision-Date: 2016-05-19 13:51-0300\n" +"PO-Revision-Date: 2016-05-24 18:51-0300\n" "Language-Team: pt_BR \n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" "MIME-Version: 1.0\n" @@ -21,8 +21,7 @@ msgstr "" #: core.py:413 msgid "Please update your e-mail address in your profile page, right now it is empty!" -msgstr "" -"Por favor atualize seu endereço de e-mail em seu perfil, faça-o agora pois ele está vazio!" +msgstr "Por favor atualize seu endereço de e-mail em seu perfil, faça-o agora pois ele está vazio!" #: importers.py:93 msgid "The file you uploaded has two headers with the same name." @@ -72,22 +71,19 @@ msgstr "Usuários Autenticados" #: exporter/csv_export.py:91 msgid "" -"Oops, the project does not have tasks to export, if you are the " -"owner add some tasks" +"Oops, the project does not have tasks to export, if you are the owner add " +"some tasks" msgstr "" -"Oops, o projeto não tem tarefas para exportar, se você é o " -"priprietário adicione algumas tarefas" +"Oops, o projeto não tem tarefas para exportar, se você é o priprietário " +"adicione algumas tarefas" #: exporter/csv_export.py:97 msgid "" -"Oops, there are no Task Runs yet to export, invite some users to " -"participate" +"Oops, there are no Task Runs yet to export, invite some users to participate" msgstr "" -"Oops, não existem execuções para exportar, convide usuários para " -"participar" +"Oops, não existem execuções para exportar, convide usuários para participar" -#: forms/forms.py:40 forms/forms.py:346 -#: themes/pybossa-contribua-theme/templates/stats/index.html:18 +#: forms/forms.py:40 forms/forms.py:346 themes/pybossa-contribua-theme/templates/stats/index.html:18 msgid "Name" msgstr "Nome" @@ -145,41 +141,35 @@ msgstr "Senha (deixe em branco para nenhuma alteração)" msgid "Webhook" msgstr "" -#: forms/forms.py:80 -#: themes/pybossa-contribua-theme/templates/projects/task_settings.html:41 +#: forms/forms.py:80 themes/pybossa-contribua-theme/templates/projects/task_settings.html:41 #: view/projects.py:1206 msgid "Redundancy" msgstr "Redundância" #: forms/forms.py:84 msgid "" -"Number of answers should be a " -"value between 1 and 1,000" +"Number of answers should be a value between 1 " +"and 1,000" msgstr "" -"Número de respostas deve ser um " -"valor entre 1 e 1,000" +"Número de respostas deve ser um valor entre 1 " +"e 1,000" #: forms/forms.py:89 msgid "Task IDs" msgstr "IDs das tarefas" -#: forms/forms.py:93 -#: themes/pybossa-contribua-theme/templates/projects/task_settings.html:25 +#: forms/forms.py:93 themes/pybossa-contribua-theme/templates/projects/task_settings.html:25 msgid "Priority" msgstr "Prioridade" #: forms/forms.py:96 msgid "" -"Priority should be a value between " -"0.0 and 1.0" +"Priority should be a value between 0.0 and 1.0" msgstr "" -"Prioridade deve ser um valor entre " -"0.0 e 1.0" +"Prioridade deve ser um valor entre 0.0 e 1.0" -#: forms/forms.py:103 -#: themes/pybossa-contribua-theme/templates/projects/task_scheduler.html:11 -#: themes/pybossa-contribua-theme/templates/projects/task_settings.html:16 -#: view/projects.py:1238 +#: forms/forms.py:103 themes/pybossa-contribua-theme/templates/projects/task_scheduler.html:11 +#: themes/pybossa-contribua-theme/templates/projects/task_settings.html:16 view/projects.py:1238 msgid "Task Scheduler" msgstr "Escalonador de tarefas" @@ -503,19 +493,18 @@ msgstr "Só mais um passo, por favor" #: themes/pybossa-contribua-theme/templates/account/account_validation.html:7 msgid "" -"In order to confirm your identity, we've sent an email to the address you just provided. " -"Please, check it out and click on the link you'll find to create your account at" +"In order to confirm your identity, we've sent an email to the address you just provided. Please, " +"check it out and click on the link you'll find to create your account at" msgstr "" -"A fim de confirmar sua identidade, nós enviamos um email para o endereço que você " -"forneceu. Por favor, verifique e clique no link que você encontrar para criar sua conta em" +"A fim de confirmar sua identidade, nós enviamos um email para o endereço que você forneceu. Por " +"favor, verifique e clique no link que você encontrar para criar sua conta em" #: themes/pybossa-contribua-theme/templates/account/account_validation.html:8 msgid "" -"If you are not receiving the email, please check the junk folder. If it's not there " -"please drop us an email to" +"If you are not receiving the email, please check the junk folder. If it's not there please drop us an " +"email to" msgstr "" -"Se você não receber o email, por favor verifique sua lixeira. E se não encontrar, mande " -"um email para" +"Se você não receber o email, por favor verifique sua lixeira. E se não encontrar, mande um email para" #: themes/pybossa-contribua-theme/templates/account/account_validation.html:9 msgid "In the meantime, you can check some of the amazing" @@ -868,19 +857,15 @@ msgid "Danger Zone!" msgstr "Zona Perigosa!" #: themes/pybossa-contribua-theme/templates/admin/del_category.html:12 -msgid "" -"Deleting the category will remove it from all the projects! This operation cannot be " -"undone!" +msgid "Deleting the category will remove it from all the projects! This operation cannot be undone!" msgstr "" -"Removendo a categoria irá removê-la de todas as aplicações! Esta operação não pode ser " -"desfeita!" +"Removendo a categoria irá removê-la de todas as aplicações! Esta operação não pode ser desfeita!" #: themes/pybossa-contribua-theme/templates/admin/del_category.html:18 msgid "No, do not delete it" msgstr "Não, não apague isto" -#: themes/pybossa-contribua-theme/templates/admin/index.html:14 view/admin.py:388 -#: view/admin.py:401 +#: themes/pybossa-contribua-theme/templates/admin/index.html:14 view/admin.py:388 view/admin.py:401 msgid "Dashboard" msgstr "" @@ -958,8 +943,7 @@ msgstr "Gerenciar projetos em destaque" msgid "Update Category" msgstr "Atualizar Categoria" -#: themes/pybossa-contribua-theme/templates/admin/users.html:11 view/admin.py:135 -#: view/admin.py:139 +#: themes/pybossa-contribua-theme/templates/admin/users.html:11 view/admin.py:135 view/admin.py:139 msgid "Manage Admin Users" msgstr "Gerenciar usuários administradores" @@ -981,19 +965,17 @@ msgstr "Usuários atuais com privilégio de administrador" #: themes/pybossa-contribua-theme/templates/home/_about.html:5 msgid "" -"PyBossa is a free, open-source crowd-sourcing and micro-tasking platform. It enables " -"people to create and run projects that utilise online assistance in performing tasks that " -"require human cognition such as image classification, transcription, geocoding and more. " -"PyBossa is there to help researchers, civic hackers and developers to create projects " -"where anyone around the world with some time, interest and an internet connection can " -"contribute." -msgstr "" -"PyBossa é uma plataforma open-source, crowd-sourcing e micro-tasking. Ele permite que as " -"pessoas criem e executem projetos que utilizam assistência online na execução de tarefas " -"que requerem cognição humana, tais como classificação de imagens, transcrição, " -"geocodificação e muito mais. PyBossa foi criado para ajudar pesquisadores, hackers " -"cívicos e desenvolvedores a criar projetos onde qualquer pessoa no mundo com algum tempo, " -"interesse e uma conexão à internet pode contribuir." +"PyBossa is a free, open-source crowd-sourcing and micro-tasking platform. It enables people to create " +"and run projects that utilise online assistance in performing tasks that require human cognition such " +"as image classification, transcription, geocoding and more. PyBossa is there to help researchers, " +"civic hackers and developers to create projects where anyone around the world with some time, " +"interest and an internet connection can contribute." +msgstr "" +"PyBossa é uma plataforma open-source, crowd-sourcing e micro-tasking. Ele permite que as pessoas " +"criem e executem projetos que utilizam assistência online na execução de tarefas que requerem " +"cognição humana, tais como classificação de imagens, transcrição, geocodificação e muito mais. " +"PyBossa foi criado para ajudar pesquisadores, hackers cívicos e desenvolvedores a criar projetos onde " +"qualquer pessoa no mundo com algum tempo, interesse e uma conexão à internet pode contribuir." #: themes/pybossa-contribua-theme/templates/home/_about.html:8 msgid "PyBossa is different to existing efforts:" @@ -1006,31 +988,31 @@ msgstr "É 100%% open-source" #: themes/pybossa-contribua-theme/templates/home/_about.html:11 msgid "" -"Unlike, say, “mechanical turk” style projects, PyBossa is not designed to handle payment " -"or money — it is designed to support volunteer-driven projects." +"Unlike, say, “mechanical turk” style projects, PyBossa is not designed to handle payment or money — " +"it is designed to support volunteer-driven projects." msgstr "" -"Ao contrário de, digamos, projetos estilo “mechanical turk”, PyBossa não é projetado para " -"com pagamento ou dinheiro — se destina a apoiar projetos conduzidos por voluntários." +"Ao contrário de, digamos, projetos estilo “mechanical turk”, PyBossa não é projetado para com " +"pagamento ou dinheiro — se destina a apoiar projetos conduzidos por voluntários." #: themes/pybossa-contribua-theme/templates/home/_about.html:13 msgid "" -"It's designed as a platform and framework for developing deploying crowd-sourcing and " -"microtasking project rather than being a crowd-sourcing project itself. Individual crowd-" -"sourcing projects are written as simple snippets of Javascript and HTML which are then " -"deployed on a PyBossa instance (such as" +"It's designed as a platform and framework for developing deploying crowd-sourcing and microtasking " +"project rather than being a crowd-sourcing project itself. Individual crowd-sourcing projects are " +"written as simple snippets of Javascript and HTML which are then deployed on a PyBossa instance (such " +"as" msgstr "" -"Ele foi projetado como uma estrutura e plataforma para desenvolver a implantação de " -"projetos de crowd-sourcing e microtasking ao invés de ser em sí um projeto de crowd-" -"sourcing.Projetos crowd-sourcing individuais são escritos como trechos simples em " -"Javascript e HTML que são implantados em uma instância PyBossa(como o" +"Ele foi projetado como uma estrutura e plataforma para desenvolver a implantação de projetos de crowd-" +"sourcing e microtasking ao invés de ser em sí um projeto de crowd-sourcing.Projetos crowd-sourcing " +"individuais são escritos como trechos simples em Javascript e HTML que são implantados em uma " +"instância PyBossa(como o" #: themes/pybossa-contribua-theme/templates/home/_about.html:13 msgid "" -"This way one can easily develop custom projects while using the PyBossa platform to store " -"your data, manage users, and handle workflow" +"This way one can easily develop custom projects while using the PyBossa platform to store your data, " +"manage users, and handle workflow" msgstr "" -"Desta forma, pode-se facilmente desenvolver projetos personalizados ao usar a plataforma " -"PyBossa para armazenar seus dados, gerenciar usuários e lidar com o fluxo de trabalho" +"Desta forma, pode-se facilmente desenvolver projetos personalizados ao usar a plataforma PyBossa para " +"armazenar seus dados, gerenciar usuários e lidar com o fluxo de trabalho" #: themes/pybossa-contribua-theme/templates/home/_about.html:18 msgid "You can read more about the architecture in the" @@ -1054,10 +1036,8 @@ msgid "Statistics" msgstr "Estatísticas" #: themes/pybossa-contribua-theme/templates/home/_about.html:23 -msgid "" -" PyBossa provides individual statistics for every project in the system, as well as a" -msgstr "" -" PyBossa fornece estatísticas individuais para qualquer projeto do sistema, bem como uma" +msgid " PyBossa provides individual statistics for every project in the system, as well as a" +msgstr " PyBossa fornece estatísticas individuais para qualquer projeto do sistema, bem como uma" #: themes/pybossa-contribua-theme/templates/home/_about.html:23 msgid "general overview about the system like total number of users, tasks, etc" @@ -1329,10 +1309,8 @@ msgid "If you delete the project and its tasks, it will be gone forever!" msgstr "Se você excluir o projeto e suas tarefas, ele não poderar ser recuperado!" #: themes/pybossa-contribua-theme/templates/projects/delete.html:18 -msgid "" -"Are you sure you want to delete this project and all its tasks and associated task runs?" -msgstr "" -"Você está certo que deseja excluir o projeto, suas tarefas e as execuções das tarefas?" +msgid "Are you sure you want to delete this project and all its tasks and associated task runs?" +msgstr "Você está certo que deseja excluir o projeto, suas tarefas e as execuções das tarefas?" #: themes/pybossa-contribua-theme/templates/projects/delete.html:21 msgid "No, do not delete it!" @@ -1384,11 +1362,11 @@ msgstr "IMPORTANTE" #: themes/pybossa-contribua-theme/templates/projects/export.html:55 msgid "" -"This export option stills in beta mode and may fail in the CKAN server. If you get an " -"error, please send an e-mail to info@pybossa.com" +"This export option stills in beta mode and may fail in the CKAN server. If you get an error, please " +"send an e-mail to info@pybossa.com" msgstr "" -"Esta opção de exportação está em modo beta e pode não funcionar no servidor CKAN. Se você " -"receber um erro, por favor mande um e-mail para info@pybossa.com" +"Esta opção de exportação está em modo beta e pode não funcionar no servidor CKAN. Se você receber um " +"erro, por favor mande um e-mail para info@pybossa.com" #: themes/pybossa-contribua-theme/templates/projects/export.html:60 msgid "You don't have a Datahub.io API key in your" @@ -1453,11 +1431,10 @@ msgid "" "it \n" " · How? Explain how your project " "works \n" -" · How you can help: Explain to the volunteers how they can help and " -"contribute to the goal of your " -"project \n" -" · Will you help make a difference? Explain to the volunteers why their " -"contribution is essential and how the result of your project can help change " +" · How you can help: Explain to the volunteers how they can help and contribute to the " +"goal of your project \n" +" · Will you help make a difference? Explain to the volunteers why their contribution " +"is essential and how the result of your project can help change " "things! \n" " (you can use Markdown to give format to your description!)" msgstr "" @@ -1466,10 +1443,10 @@ msgstr "" "alcançar \n" " · Como? Explique como seu projeto " "funciona \n" -" · como ajudar: Explique aos voluntátios como eles podem contribuir para o " -"objetivo do seu projeto \n" -" · você ajudará a fazer a diferença? Explique aos voluntários porque sua " -"contribuição é essencial e como o resultado do seu projeto pode mudar as " +" · como ajudar: Explique aos voluntátios como eles podem contribuir para o objetivo do " +"seu projeto \n" +" · você ajudará a fazer a diferença? Explique aos voluntários porque sua contribuição " +"é essencial e como o resultado do seu projeto pode mudar as " "coisas! \n" " (você pode utilizar Markdown para formatar sua descrição!)" @@ -1505,11 +1482,11 @@ msgstr "Enviar" #: themes/pybossa-contribua-theme/templates/projects/presenter.html:22 msgid "" -"Sorry, you've contributed to all the tasks for this project, but this project still needs " -"more volunteers, so please spread the word!" +"Sorry, you've contributed to all the tasks for this project, but this project still needs more " +"volunteers, so please spread the word!" msgstr "" -"Desculpe, você contribuiu para todas as tarefas deste projeto, mas este projeto ainda " -"precisa de mais voluntários, então convide outros colaboradores!" +"Desculpe, você contribuiu para todas as tarefas deste projeto, mas este projeto ainda precisa de mais " +"voluntários, então convide outros colaboradores!" #: themes/pybossa-contribua-theme/templates/projects/settings.html:14 msgid "Project Settings" @@ -1696,8 +1673,7 @@ msgid "Close" msgstr "Fechar" #: themes/pybossa-contribua-theme/templates/projects/task_priority.html:13 -#: themes/pybossa-contribua-theme/templates/projects/task_settings.html:23 -#: view/projects.py:1285 +#: themes/pybossa-contribua-theme/templates/projects/task_settings.html:23 view/projects.py:1285 msgid "Task Priority" msgstr "Prioridade da tarefa" @@ -1710,13 +1686,10 @@ msgid "priority" msgstr "prioridade" #: themes/pybossa-contribua-theme/templates/projects/task_priority.html:14 -msgid "" -"of one or more tasks, providing a list of task IDs separated by commas. The lowest " -"priority is" +msgid "of one or more tasks, providing a list of task IDs separated by commas. The lowest priority is" msgstr "" "de uma ou mais tarefas,\n" -" fornecendo uma lista de IDs das tarefas separadas por vírgula. A " -"prioridade\n" +" fornecendo uma lista de IDs das tarefas separadas por vírgula. A prioridade\n" " mais baixa é" #: themes/pybossa-contribua-theme/templates/projects/task_priority.html:14 @@ -1915,11 +1888,11 @@ msgstr "O primeiro número representa o total de respostas submetidas para a tar #: themes/pybossa-contribua-theme/templates/projects/tasks_browse.html:18 msgid "" -"This redundancy method will help to detect errors, typos, data forging, etc. when the " -"task has been completed" +"This redundancy method will help to detect errors, typos, data forging, etc. when the task has been " +"completed" msgstr "" -"Este método de redundância vai ajudar a detectar erros, erros de digitação, forjamento de " -"dados, etc., quando a tarefa for concluída" +"Este método de redundância vai ajudar a detectar erros, erros de digitação, forjamento de dados, " +"etc., quando a tarefa for concluída" #: themes/pybossa-contribua-theme/templates/projects/tasks_browse.html:18 msgid "second number" @@ -1987,11 +1960,10 @@ msgstr "De um arquivo CSV" #: themes/pybossa-contribua-theme/templates/projects/importers/csv.html:19 msgid "" -"Please provide a URL (i.e. DropBox, Box, Ubuntu One, etc. public link) to a CSV file with " -"data for" +"Please provide a URL (i.e. DropBox, Box, Ubuntu One, etc. public link) to a CSV file with data for" msgstr "" -"Por favor forneça uma URL (i.e. DropBox, Box, Ubuntu One, etc. link público) para o " -"arquivo CSV com dados para" +"Por favor forneça uma URL (i.e. DropBox, Box, Ubuntu One, etc. link público) para o arquivo CSV com " +"dados para" #: themes/pybossa-contribua-theme/templates/projects/importers/csv.html:19 #: themes/pybossa-contribua-theme/templates/projects/importers/dropbox.html:25 @@ -2031,8 +2003,7 @@ msgstr "De um projeto EpiCollect Plus" #: themes/pybossa-contribua-theme/templates/projects/importers/epicollect.html:19 msgid "Please provide an EpiCollect Plus project name to import its data for" -msgstr "" -"Por favor forneça o nome de um projeto EpiCollect Plus de modo a importar seus dados para" +msgstr "Por favor forneça o nome de um projeto EpiCollect Plus de modo a importar seus dados para" #: themes/pybossa-contribua-theme/templates/projects/importers/epicollect.html:21 msgid "The name of the public EpiCollect Plus project" @@ -2449,13 +2420,12 @@ msgstr "Oooops, email/senha incorreto" #: view/account.py:112 msgid "Ooops, we didn't find you in the system, did you sign up?" -msgstr "" -"Ooops, não encontramos você no sistema, você se cadastrou?" +msgstr "Ooops, não encontramos você no sistema, você se cadastrou?" -#: view/account.py:117 view/account.py:216 view/account.py:491 view/account.py:507 -#: view/account.py:521 view/account.py:554 view/admin.py:268 view/admin.py:349 -#: view/projects.py:219 view/projects.py:276 view/projects.py:415 view/projects.py:1225 -#: view/projects.py:1276 view/projects.py:1321 view/projects.py:1396 view/projects.py:1441 +#: view/account.py:117 view/account.py:216 view/account.py:491 view/account.py:507 view/account.py:521 +#: view/account.py:554 view/admin.py:268 view/admin.py:349 view/projects.py:219 view/projects.py:276 +#: view/projects.py:415 view/projects.py:1225 view/projects.py:1276 view/projects.py:1321 +#: view/projects.py:1396 view/projects.py:1441 msgid "Please correct the errors" msgstr "Por favor corrija os erros" @@ -2488,20 +2458,18 @@ msgid "Profile" msgstr "Perfil" #: view/account.py:448 -msgid "" -"Your avatar has been updated! It may take some minutes to refresh..." +msgid "Your avatar has been updated! It may take some minutes to refresh..." msgstr "" -"Seu avatar está sendo atualizado! pode demorar alguns minutos para " -"atualização..." +"Seu avatar está sendo atualizado! pode demorar alguns minutos para atualização..." #: view/account.py:478 #, python-format msgid "" -"An email has been sent to verify your new email: %s. Once you " -"verify it, it will be updated.email_addr" +"An email has been sent to verify your new email: %s. Once you verify it, it " +"will be updated.email_addr" msgstr "" -"Um email foi enviado para veirificar seu novo email: %s. Uma vez " -"que você verificar, será atualizado.email_addr" +"Um email foi enviado para veirificar seu novo email: %s. Uma vez que você " +"verificar, será atualizado.email_addr" #: view/account.py:489 view/account.py:519 msgid "Your profile has been updated!" @@ -2525,11 +2493,11 @@ msgstr "Nós lhe enviamos um email com as instruções para recuperação de sua #: view/account.py:609 msgid "" -"We don't have this email in our records. You may have signed up with a different email or " -"used Twitter, Facebook, or Google to sign-in" +"We don't have this email in our records. You may have signed up with a different email or used " +"Twitter, Facebook, or Google to sign-in" msgstr "" -"Nós não temos este email em nossos registros. Você deve ter entrado com um email " -"diferente ou usado sua conta do Twitter, Facebook ou Google" +"Nós não temos este email em nossos registros. Você deve ter entrado com um email diferente ou usado " +"sua conta do Twitter, Facebook ou Google" #: view/account.py:614 msgid "Something went wrong, please correct the errors on the form" @@ -2549,11 +2517,10 @@ msgstr "Categoria removida" #: view/admin.py:306 msgid "" -"Sorry, it is not possible to delete the only available category. You can modify it, " -"click the edit button" +"Sorry, it is not possible to delete the only available category. You can modify it, click the edit " +"button" msgstr "" -"Desculpe, não é possível remover a única categoria disponível. Você pode modificá-la no " -"botão Editar" +"Desculpe, não é possível remover a única categoria disponível. Você pode modificá-la no botão Editar" #: view/admin.py:345 msgid "Category updated" @@ -2593,11 +2560,9 @@ msgstr "import de CSV" #: view/projects.py:286 msgid "" -" or download the project bundle and run the createTasks.py script in " -"your computer" +" or download the project bundle and run the createTasks.py script in your computer" msgstr "" -" ou faça o download do pacote e execute o script createTasks.py em seu " -"computador" +" ou faça o download do pacote e execute o script createTasks.py em seu computador" #: view/projects.py:352 msgid "Project deleted!" @@ -2609,11 +2574,11 @@ msgstr "Projeto atualizado!" #: view/projects.py:434 msgid "" -"Your project thumbnail has been updated! It may take " -"some minutes to refresh..." +"Your project thumbnail has been updated! It may take some minutes " +"to refresh..." msgstr "" -"A miniatura do seu projeto foi atualizada! Pode demorar " -"alguns minutos para atualização..." +"A miniatura do seu projeto foi atualizada! Pode demorar alguns " +"minutos para atualização..." #: view/projects.py:437 msgid "You must provide a file to change the avatar" @@ -2625,11 +2590,11 @@ msgstr "Importando tarefas, isto pode demorar um pouco, aguarde..." #: view/projects.py:573 msgid "" -"You're trying to import a large amount of tasks, so please be patient. You " -"will receive an email when the tasks are ready." +"You're trying to import a large amount of tasks, so please be patient. You will receive an " +"email when the tasks are ready." msgstr "" -"Você está tentando importar uma grande quantidade de tarefas, por favor seja " -"paciente. Você receberá um e-mail quando as tarefas estiverem prontas." +"Você está tentando importar uma grande quantidade de tarefas, por favor seja paciente. " +"Você receberá um e-mail quando as tarefas estiverem prontas." #: view/projects.py:616 msgid "Success! Tasks will be imported daily." @@ -2641,13 +2606,11 @@ msgstr "Desculpe, senha incorreta" #: view/projects.py:700 msgid "Ooops! You are an anonymous user and will not get any credit for your contributions." -msgstr "" -"Ooops! Você é um usuário anônimo e não ganhará nenhum crédito por suas contribuições." +msgstr "Ooops! Você é um usuário anônimo e não ganhará nenhum crédito por suas contribuições." #: view/projects.py:719 view/projects.py:771 msgid "Sorry, but this project is still a draft and does not have a task presenter." -msgstr "" -"Desculpe, mas este projeto ainda é um rascunho e não tem nenhum visualizadorde tarefas." +msgstr "Desculpe, mas este projeto ainda é um rascunho e não tem nenhum visualizadorde tarefas." #: view/projects.py:899 msgid "All the tasks and associated task runs have been deleted" @@ -2663,19 +2626,16 @@ msgstr "Dados exportados para " #: view/projects.py:1063 msgid "" -"Oops, the project does not have tasks to export, if you are the owner " -"add some tasks" +"Oops, the project does not have tasks to export, if you are the owner add some " +"tasks" msgstr "" -"Oops, o projeto não tem tarefas para exportar, se você é o " -"proprietário adicione algumas tarefas" +"Oops, o projeto não tem tarefas para exportar, se você é o proprietário " +"adicione algumas tarefas" #: view/projects.py:1069 msgid "" -"Oops, there are no Task Runs yet to export, invite some users to " -"participate" -msgstr "" -"Oops, não existem execuções para exportar,convide usuários para " -"participar" +"Oops, there are no Task Runs yet to export, invite some users to participate" +msgstr "Oops, não existem execuções para exportar,convide usuários para participar" #: view/projects.py:1221 msgid "Redundancy of Tasks updated!" @@ -2801,8 +2761,7 @@ msgid "Our records show that you use your" msgstr "" msgid "" -"account to sign in. Please use the same account to sign-in again. If you forgot the " -"password to your" +"account to sign in. Please use the same account to sign-in again. If you forgot the password to your" msgstr "" msgid "account, please contact" @@ -2827,8 +2786,8 @@ msgid "Click here to confirm your e-mail address and create your account" msgstr "" msgid "" -"Online assistance in performing tasks that require human cognition, knowledge or " -"intelligence such as image classification, transcription, geocoding and more!" +"Online assistance in performing tasks that require human cognition, knowledge or intelligence such as " +"image classification, transcription, geocoding and more!" msgstr "" "Assistência online para execução de tarefas que requerem cognição humana, conhecimento ou " "inteligência, como classificação de imagens, transcrição, geocodificação e muito mais!" @@ -2884,8 +2843,7 @@ msgid "" " priority is" msgstr "" "de uma ou mais tarefas,\n" -" fornecendo uma lista de IDs das tarefas separadas por vírgula. A " -"prioridade\n" +" fornecendo uma lista de IDs das tarefas separadas por vírgula. A prioridade\n" " mais baixa é" msgid "" @@ -2920,11 +2878,11 @@ msgid "" "returns a task\n" " randomly --a user could get the same task twice or more\n" " times" - msgstr "" "Retorna uma tarefa\n" " aleatória - um usuário pode receber a tarefa duas ou mais\n" " vezes" + msgid "" "If you delete all the\n" " tasks and task runs they will be gone\n" @@ -2942,16 +2900,19 @@ msgstr "" " nada" # view/projects.py:807 -msgid "Oops! You have to sign in to participate in WikiLibras" -" project" +msgid "" +"Oops! You have to sign in to participate in WikiLibras " +"project" msgstr "Oops! Você precisa se cadastrar para participar do projeto WikiLibras" -msgid "Oops! You have to sign in to participate in Corretor de Sinais" -" project" +msgid "" +"Oops! You have to sign in to participate in Corretor de Sinais " +"project" msgstr "Oops! Você precisa se cadastrar para participar do projeto Corretor de Sinais" -msgid "Oops! You have to sign in to participate in Validador de Sinais" -" project" +msgid "" +"Oops! You have to sign in to participate in Validador de Sinais " +"project" msgstr "Oops! Você precisa se cadastrar para participar do projeto Validador de Sinais" # themes/default/templates/projects/index.html:30 @@ -2969,3 +2930,30 @@ msgstr "atividade" # themes/default/templates/projects/index.html:33 msgid "progress" msgstr "progresso" + +# forms/forms.py:283 +msgid "You want to participate as" +msgstr "Deseja atuar como" + +# view/projects.py:758 +# view/projects.py:815 +msgid "" +"Oops! Your profile (Colaborador) does not have access to the Validador de Sinais " +"project" +msgstr "Oops! O seu perfil (Colaborador) não tem acesso ao projeto Validador de Sinais" + +msgid "" +"Oops! Your profile (Colaborador) does not have access to the Corretor de Sinais " +"project" +msgstr "Oops! O seu perfil (Colaborador) não tem acesso ao projeto Corretor de Sinais" + +msgid "" +"Oops! Your profile (Animador) does not have access to the Validador de Sinais " +"project" +msgstr "Oops! O seu perfil (Animador) não tem acesso ao projeto Validador de Sinais" + +msgid "" +"Oops! Your profile (Especialista) does not have access to the Corretor de Sinais " +"project" +msgstr "Oops! O seu perfil (Especialista) não tem acesso ao projeto Corretor de Sinais" + diff --git a/pybossa/view/account.py b/pybossa/view/account.py index c4da480..e3b4e9d 100644 --- a/pybossa/view/account.py +++ b/pybossa/view/account.py @@ -199,10 +199,12 @@ def register(): """ form = RegisterForm(request.form) + form.set_profile_choices(current_app.config.get('PROFILES')) if request.method == 'POST' and form.validate(): account = dict(fullname=form.fullname.data, name=form.name.data, email_addr=form.email_addr.data, - password=form.password.data) + password=form.password.data, profile=form.profile.data, + locale=current_app.config.get('DEFAULT_LOCALE')) confirm_url = get_email_confirmation_url(account) if current_app.config.get('ACCOUNT_CONFIRMATION_DISABLED'): return _create_account(account) @@ -268,10 +270,16 @@ def confirm_account(): def _create_account(user_data): + profile = user_repo.get_profile_by(name=user_data['profile']) + if profile is None: + return + new_user = model.user.User(fullname=user_data['fullname'], name=user_data['name'], email_addr=user_data['email_addr'], - valid_email=True) + valid_email=True, + profile_id=profile.id, + locale=user_data['locale']) new_user.set_password(user_data['password']) user_repo.save(new_user) flash(gettext('Thanks for signing-up'), 'success') diff --git a/pybossa/view/projects.py b/pybossa/view/projects.py index bd64f63..4c6b820 100644 --- a/pybossa/view/projects.py +++ b/pybossa/view/projects.py @@ -738,7 +738,7 @@ def task_presenter(short_name, task_id): if not project.allow_anonymous_contributors: msg = ("Oops! You have to sign in to participate in " "%s" - "project" % project.name) + " project" % project.name) flash(gettext(msg), 'warning') return redirect(url_for('account.signin', next=url_for('.presenter', @@ -752,6 +752,13 @@ def task_presenter(short_name, task_id): short_name=short_name, task_id=task_id) url = url_for('account.signin', next=next_url) flash(msg_1 + "Sign in now!", "warning") + + if not current_user.is_anonymous() and not user_repo.profile_has_access(current_user, project.short_name): + profile = user_repo.get_profile(current_user.profile_id) + msg = "Oops! Your profile (%s) does not have access to the %s \ + project" % (profile.name, project.name) + flash(gettext(msg), 'warning') + return redirect(url_for('project.index')) title = project_title(project, "Contribute") template_args = {"project": project, "title": title, "owner": owner} @@ -802,6 +809,13 @@ def presenter(short_name): title = project_title(project, "Contribute") template_args = {"project": project, "title": title, "owner": owner, "invite_new_volunteers": invite_new_volunteers(project)} + + if not current_user.is_anonymous() and not user_repo.profile_has_access(current_user, project.short_name): + profile = user_repo.get_profile(current_user.profile_id) + msg = "Oops! Your profile (%s) does not have access to the %s \ + project" % (profile.name, project.name) + flash(gettext(msg), 'warning') + return redirect(url_for('project.index')) if not project.allow_anonymous_contributors and current_user.is_anonymous(): msg = "Oops! You have to sign in to participate in %s \ diff --git a/settings_local.py.tmpl b/settings_local.py.tmpl index bdba3c1..42ffc3f 100644 --- a/settings_local.py.tmpl +++ b/settings_local.py.tmpl @@ -60,11 +60,15 @@ CONTACT_TWITTER = 'PyBossa' ## NOTE: You need to create a symbolic link to the translations folder, otherwise ## this wont work. ## ln -s pybossa/themes/your-theme/translations pybossa/translations -DEFAULT_LOCALE = 'pt_BR' +DEFAULT_LOCALE = u'pt_BR' LOCALES = [('en', 'English'), ('es', u'Español'), ('it', 'Italiano'), ('fr', u'Français'), ('ja', u'日本語'),('pt_BR', u'Português (BR)')] +# Profiles +PROFILES = [('Colaborador','Colaborador'), ('Animador','Animador 3D'), ('Especialista', 'Especialista em LIBRAS')] + + ## list of administrator emails to which error emails get sent # ADMINS = ['me@sysadmin.org'] -- libgit2 0.21.2