From 48bd6480172acd89f3f053896be0a096d66c45ea Mon Sep 17 00:00:00 2001 From: Rafael J P D Date: Mon, 1 Nov 2021 21:52:46 -0300 Subject: [PATCH 01/10] remove arquivos e estrutura legada --- Dockerfile | 32 - dev.env | 20 - docker-entrypoint.sh | 38 -- docker-start-worker.sh | 3 - prod.env | 26 - requirements.txt | 14 - setup.py | 57 -- spf/core/__init__.py | 0 spf/core/admin.py | 7 - spf/core/apps.py | 6 - spf/core/controller.py | 87 --- spf/core/decorators.py | 34 -- spf/core/fixtures/group.json | 1 - spf/core/fixtures/user.json | 1 - spf/core/forms.py | 53 -- spf/core/locale/es/LC_MESSAGES/django.po | 547 ------------------ spf/core/locale/pt/LC_MESSAGES/django.po | 546 ----------------- .../commands/make_messages_no_fuzzy.py | 5 - spf/core/migrations/__init__.py | 0 spf/core/models.py | 67 --- spf/core/static/css/style.css | 10 - spf/core/static/img/logo-scielo.svg | 1 - spf/core/tasks.py | 19 - spf/core/templates/base.html | 80 --- spf/core/templates/faq.html | 12 - spf/core/templates/index.html | 109 ---- .../templates/ingress/article_files_list.html | 79 --- spf/core/templates/ingress/package_list.html | 70 --- .../templates/ingress/package_upload.html | 28 - spf/core/templates/journal/journal_list.html | 73 --- spf/core/templates/tracking/event_list.html | 80 --- spf/core/templates/user/add.html | 49 -- spf/core/templates/user/change_password.html | 31 - spf/core/templates/user/groups_edit.html | 88 --- spf/core/templates/user/login.html | 28 - spf/core/templates/user/profile.html | 34 -- spf/core/templates/user/profile_edit.html | 36 -- spf/core/templates/user/register.html | 45 -- spf/core/templatetags/__init__.py | 0 spf/core/templatetags/spf_extras.py | 62 -- spf/core/tests.py | 3 - spf/core/urls.py | 37 -- spf/core/views.py | 352 ----------- spf/manage.py | 22 - spf/spf/__init__.py | 3 - spf/spf/asgi.py | 16 - spf/spf/celery.py | 10 - spf/spf/settings.py | 117 ---- spf/spf/urls.py | 23 - spf/spf/wsgi.py | 16 - 50 files changed, 3077 deletions(-) delete mode 100644 Dockerfile delete mode 100644 dev.env delete mode 100644 docker-entrypoint.sh delete mode 100644 docker-start-worker.sh delete mode 100644 prod.env delete mode 100644 requirements.txt delete mode 100755 setup.py delete mode 100644 spf/core/__init__.py delete mode 100644 spf/core/admin.py delete mode 100644 spf/core/apps.py delete mode 100644 spf/core/controller.py delete mode 100644 spf/core/decorators.py delete mode 100644 spf/core/fixtures/group.json delete mode 100644 spf/core/fixtures/user.json delete mode 100644 spf/core/forms.py delete mode 100644 spf/core/locale/es/LC_MESSAGES/django.po delete mode 100644 spf/core/locale/pt/LC_MESSAGES/django.po delete mode 100644 spf/core/management/commands/make_messages_no_fuzzy.py delete mode 100644 spf/core/migrations/__init__.py delete mode 100644 spf/core/models.py delete mode 100644 spf/core/static/css/style.css delete mode 100644 spf/core/static/img/logo-scielo.svg delete mode 100644 spf/core/tasks.py delete mode 100644 spf/core/templates/base.html delete mode 100644 spf/core/templates/faq.html delete mode 100644 spf/core/templates/index.html delete mode 100644 spf/core/templates/ingress/article_files_list.html delete mode 100644 spf/core/templates/ingress/package_list.html delete mode 100644 spf/core/templates/ingress/package_upload.html delete mode 100644 spf/core/templates/journal/journal_list.html delete mode 100644 spf/core/templates/tracking/event_list.html delete mode 100644 spf/core/templates/user/add.html delete mode 100644 spf/core/templates/user/change_password.html delete mode 100644 spf/core/templates/user/groups_edit.html delete mode 100644 spf/core/templates/user/login.html delete mode 100644 spf/core/templates/user/profile.html delete mode 100644 spf/core/templates/user/profile_edit.html delete mode 100644 spf/core/templates/user/register.html delete mode 100644 spf/core/templatetags/__init__.py delete mode 100644 spf/core/templatetags/spf_extras.py delete mode 100644 spf/core/tests.py delete mode 100644 spf/core/urls.py delete mode 100644 spf/core/views.py delete mode 100755 spf/manage.py delete mode 100644 spf/spf/__init__.py delete mode 100644 spf/spf/asgi.py delete mode 100644 spf/spf/celery.py delete mode 100644 spf/spf/settings.py delete mode 100644 spf/spf/urls.py delete mode 100644 spf/spf/wsgi.py diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 5a823e0..0000000 --- a/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -FROM python:3.9.6-alpine - -LABEL MAINTAINER scielo-dev@googlegroups.com -ENV PYTHONDONTWRITEBYTECODE 1 -ENV PYTHONUNBUFFERED 1 - -RUN apk --update add --no-cache \ - git \ - gcc \ - build-base \ - libxml2-dev \ - libxslt-dev \ - py3-lxml \ - postgresql-dev \ - libffi-dev \ - gettext-dev - -COPY . /app -WORKDIR /app - -RUN pip install -U pip && \ - pip install -r /app/requirements.txt - -RUN chmod +x /app/docker-entrypoint.sh -RUN chmod +x /app/docker-start-worker.sh - -RUN chown -R nobody:nobody /app -USER nobody - -EXPOSE 8000 - -ENTRYPOINT ["/app/docker-entrypoint.sh"] diff --git a/dev.env b/dev.env deleted file mode 100644 index 1b5fc74..0000000 --- a/dev.env +++ /dev/null @@ -1,20 +0,0 @@ -MINIO_HOST=172.27.0.5:9000 -MINIO_ACCESS_KEY=minioadmin -MINIO_SECRET_KEY=minioadmin -MINIO_TIMEOUT=10000 -MINIO_SECURE=false -MINIO_SCIELO_COLLECTION=spf_brazil -MINIO_SPF_DIR=packages -DATABASE_CONNECT_URL=mongodb://opac_opac_mongo_1:27017/opac -DJANGO_DEBUG=1 -DJANGO_SECRET_KEY=olamundo -DJANGO_ALLOWED_HOSTS=localhost;0.0.0.0;192.168.1.104;127.0.0.1;[::1] -DJANGO_MANAGE_MIGRATE=0 -DJANGO_MANAGE_LOAD=0 -DJANGO_ADMIN_TRANSLATE=0 -POSTGRES_DB=spf -POSTGRES_USER=postgres -POSTGRES_PASSWORD=alemanha -POSTGRES_HOST=scielo-postgres-1 -POSTGRES_PORT=5432 -CELERY_BROKER_URL=pyamqp://spf_broker_1:5672 \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100644 index f2cf197..0000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -if [ "$DJANGO_MANAGE_MIGRATE" = "1" ]; then - echo "making migrations ..." - python spf/manage.py makemigrations - echo "migrating data ..." - python spf/manage.py migrate --noinput -fi - -if [ "$DJANGO_CREATE_SUPERUSER" = "1" ]; then - echo "creating superuser ..." - python spf/manage.py createsuperuser \ - --noinput \ - --username $DJANGO_SUPERUSER_USERNAME \ - --email $DJANGO_SUPERUSER_EMAIL -fi - -if [ "$DJANGO_MANAGE_LOAD_GROUP" = "1" ]; then - echo "loading groups ..." - python spf/manage.py loaddata group -fi - -if [ "$DJANGO_MANAGE_LOAD_USER" = "1" ]; then - echo "loading users ..." - python spf/manage.py loaddata user -fi - -if [ "$DJANGO_ADMIN_TRANSLATE" = "1" ]; then - echo "translanting messages ..." - django-admin compilemessages -fi - -if [ "$DJANGO_COLLECTSTATIC" = "1" ]; then - echo "collecting static files ..." - python spf/manage.py collectstatic --noinput -fi - -exec "$@" diff --git a/docker-start-worker.sh b/docker-start-worker.sh deleted file mode 100644 index 5673baa..0000000 --- a/docker-start-worker.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -cd spf -celery -A spf worker -l INFO diff --git a/prod.env b/prod.env deleted file mode 100644 index ee6813e..0000000 --- a/prod.env +++ /dev/null @@ -1,26 +0,0 @@ -CELERY_BROKER_URL= -DATABASE_CONNECT_URL= -DJANGO_ADMIN_TRANSLATE=1 -DJANGO_ALLOWED_HOSTS=localhost;0.0.0.0;[::1] -DJANGO_COLLECTSTATIC=1 -DJANGO_CREATE_SUPERUSER=1 -DJANGO_DEBUG=1 -DJANGO_MANAGE_LOAD_GROUP=1 -DJANGO_MANAGE_LOAD_USER=1 -DJANGO_MANAGE_MIGRATE=1 -DJANGO_SECRET_KEY= -DJANGO_SUPERUSER_EMAIL= -DJANGO_SUPERUSER_PASSWORD= -DJANGO_SUPERUSER_USERNAME= -MINIO_ACCESS_KEY= -MINIO_HOST= -MINIO_SCIELO_COLLECTION= -MINIO_SECRET_KEY= -MINIO_SECURE= -MINIO_SPF_DIR= -MINIO_TIMEOUT= -POSTGRES_DB= -POSTGRES_HOST= -POSTGRES_PASSWORD= -POSTGRES_PORT= -POSTGRES_USER= \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 2465f38..0000000 --- a/requirements.txt +++ /dev/null @@ -1,14 +0,0 @@ -asgiref==3.4.1 -celery==5.1.2 -confusable-homoglyphs==3.2.0 -Django==3.2.5 -django-celery-results==2.2.0 -psycopg2-binary==2.9 -pytz==2021.1 -python-dateutil==2.8.2 -sqlparse==0.4.1 -lxml==4.6.3 -minio==7.1.0 --e git+https://github.com/scieloorg/opac_schema.git#egg=opac_schema --e git+https://github.com/scieloorg/dsm.git#egg=dsm --e git+https://github.com/scieloorg/scielo_v3_manager.git#egg=scielo_v3_manager \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100755 index bc8bcd3..0000000 --- a/setup.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python3 -import os, setuptools - -here = os.path.abspath(os.path.dirname(__file__)) -with open(os.path.join(here, "README.md")) as f: - README = f.read() - -requires = [ - 'asgiref', - 'celery', - 'confusable-homoglyphs', - 'Django', - 'django-celery-results', - 'pytz', - 'python-dateutil', - 'sqlparse', - 'minio', - 'lxml', - 'opac_schema', - 'dsm', - 'scielo_v3_manager', -] - -tests_require = [ -] - -setuptools.setup( - name="SciELO Publishing Framework", - version="0.1", - author="SciELO", - author_email="scielo-dev@googlegroups.com", - description="", - long_description=README, - long_description_content_type="text/markdown", - license="2-clause BSD", - packages=setuptools.find_packages( - exclude=["*.tests", "*.tests.*", "tests.*", "tests"] - ), - include_package_data=True, - extras_require={"testing": tests_require}, - install_requires=requires, - dependency_links=[ - ], - python_requires=">=3.6", - test_suite="tests", - classifiers=[ - "Development Status :: 2 - Pre-Alpha", - "Environment :: Other Environment", - "License :: OSI Approved :: BSD License", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3 :: Only", - "Topic :: Internet :: WWW/HTTP", - "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", - "Operating System :: OS Independent", - ], -) diff --git a/spf/core/__init__.py b/spf/core/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/spf/core/admin.py b/spf/core/admin.py deleted file mode 100644 index 21245b7..0000000 --- a/spf/core/admin.py +++ /dev/null @@ -1,7 +0,0 @@ -from django.contrib import admin -from .models import Event, IngressPackage, ValidationSchema, Validation - -admin.site.register(Event) -admin.site.register(IngressPackage) -admin.site.register(ValidationSchema) -admin.site.register(Validation) diff --git a/spf/core/apps.py b/spf/core/apps.py deleted file mode 100644 index 8115ae6..0000000 --- a/spf/core/apps.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.apps import AppConfig - - -class CoreConfig(AppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'core' diff --git a/spf/core/controller.py b/spf/core/controller.py deleted file mode 100644 index 8687143..0000000 --- a/spf/core/controller.py +++ /dev/null @@ -1,87 +0,0 @@ -from datetime import datetime -from django.contrib.auth.models import Group, User -from core.models import GROUP_MANAGER, SCOPE_ALL_USERS, IngressPackage, Event - - -def _is_privileged_user(user): - return GROUP_MANAGER in get_groups_names_from_user(user) or user.is_superuser or user.is_staff - - -def _get_objects_from_user_and_scope(user, scope, model_class): - if scope == SCOPE_ALL_USERS and _is_privileged_user(user): - return model_class.objects.all() - else: - return model_class.objects.filter(user=user) - - -def get_ingress_packages_from_user_and_scope(user, scope): - return _get_objects_from_user_and_scope(user, scope, IngressPackage) - - -def get_events_from_user_and_scope(user, scope): - return _get_objects_from_user_and_scope(user, scope, Event) - - -def get_user_from_username(username): - return User.objects.get(username=username) - - -def get_users(include_superuser=False): - return User.objects.filter(is_superuser=include_superuser) - - -def get_groups_names_from_user(user): - return [g.name for g in user.groups.all()] - - -def get_groups_from_user(user): - return Group.objects.filter(user=user) - - -def update_user_groups(user, user_groups): - for group in get_groups(): - if group not in user_groups: - user.groups.remove(group) - - for ug in user_groups: - user.groups.add(ug) - user.save() - - -def get_groups_from_groups_names(groups_names): - return Group.objects.filter(name__in=groups_names) - - -def get_groups(): - return Group.objects.all() - - -def add_event(user, event_name, annotation=None): - event = Event() - event.user = user - event.name = event_name - event.annotation = annotation - event.status = Event.Status.INITIATED - event.save() - - return event - - -def update_event(event, args): - for k, v in args.items(): - setattr(event, k, v) - event.datetime = datetime.utcnow() - event.save() - - return event - - -def add_ingress_package(user, event_datetime, package_name): - ip = IngressPackage() - ip.user = user - ip.datetime = event_datetime - ip.package_name = package_name - ip.status = IngressPackage.Status.RECEIVED - ip.save() - - return ip diff --git a/spf/core/decorators.py b/spf/core/decorators.py deleted file mode 100644 index 03d982b..0000000 --- a/spf/core/decorators.py +++ /dev/null @@ -1,34 +0,0 @@ -from django.contrib import messages -from django.shortcuts import redirect -from django.utils.translation import gettext as _ - - -def unauthenticated_user(view): - def wrapper(request, *args, **kwargs): - if request.user.is_authenticated: - return redirect('index') - else: - return view(request, *args, **kwargs) - - return wrapper - - -def allowed_users(allowed_groups=[]): - def decorator(view): - def wrapper(request, *args, **kwargs): - if request.user.is_superuser: - return view(request, *args, **kwargs) - elif request.user.groups.exists(): - for gn in [g.name for g in request.user.groups.all()]: - if gn in allowed_groups: - return view(request, *args, **kwargs) - messages.warning(request, - _('You do not have permission to access the requested page ') + request.path, - extra_tags='alert-warning') - return redirect('index') - messages.warning(request, - _('You do not have permission to access the requested page ') + request.path, - extra_tags='alert-warning') - return redirect('index') - return wrapper - return decorator diff --git a/spf/core/fixtures/group.json b/spf/core/fixtures/group.json deleted file mode 100644 index 25b4310..0000000 --- a/spf/core/fixtures/group.json +++ /dev/null @@ -1 +0,0 @@ -[{"model": "auth.group", "pk": 1, "fields": {"name": "operator_ingress", "permissions": [4, 12, 8, 16, 20, 25, 26, 28, 29, 30, 32, 37, 38, 39, 40, 33, 34, 36, 24]}}, {"model": "auth.group", "pk": 2, "fields": {"name": "operator_migration", "permissions": [4, 12, 8, 16, 20, 41, 42, 43, 44, 25, 26, 28, 29, 30, 32, 33, 34, 36, 24]}}, {"model": "auth.group", "pk": 3, "fields": {"name": "manager", "permissions": [4, 9, 10, 11, 12, 5, 6, 8, 13, 14, 15, 16, 20, 41, 42, 43, 44, 25, 26, 27, 28, 29, 30, 31, 32, 37, 38, 39, 40, 33, 34, 35, 36, 24]}}, {"model": "auth.group", "pk": 4, "fields": {"name": "quality_analyst", "permissions": [4, 12, 5, 8, 16, 17, 18, 20, 41, 42, 44, 26, 28, 30, 32, 37, 38, 40, 33, 34, 36, 21, 22, 24]}}] \ No newline at end of file diff --git a/spf/core/fixtures/user.json b/spf/core/fixtures/user.json deleted file mode 100644 index d19baff..0000000 --- a/spf/core/fixtures/user.json +++ /dev/null @@ -1 +0,0 @@ -[{"model": "auth.user", "pk": 1, "fields": {"password": "pbkdf2_sha256$260000$9lTnCt02OOX04bDA3VIgxR$0yRbSM7QkXtJcZWhqexUHICtV2uVSQD6RUbuEMqjG78=", "last_login": "2021-08-27T15:25:09.006Z", "is_superuser": true, "username": "superspf", "first_name": "", "last_name": "", "email": "", "is_staff": true, "is_active": true, "date_joined": "2021-08-27T15:24:57.596Z", "groups": [], "user_permissions": []}}, {"model": "auth.user", "pk": 2, "fields": {"password": "pbkdf2_sha256$260000$Zzjo7NSm4yG4xntIc129Bq$g54JaMwgFmEIM+SB9189RDNyrZmyEpXu0vHncusWMz4=", "last_login": "2021-09-14T22:34:04.101Z", "is_superuser": false, "username": "ingress1", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-08-27T15:26:36Z", "groups": [1], "user_permissions": []}}, {"model": "auth.user", "pk": 3, "fields": {"password": "pbkdf2_sha256$260000$P73ywmSRSpuf05lzXrB2IA$JkxLsy3bMBXz79U2NOMwhcz6NWfsRtETNhVpKH3MoT4=", "last_login": "2021-09-13T20:54:06.343Z", "is_superuser": false, "username": "ingress2", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-08-27T15:26:43Z", "groups": [1], "user_permissions": []}}, {"model": "auth.user", "pk": 4, "fields": {"password": "pbkdf2_sha256$260000$2Z1ZK71dXhYRWL3LAQFIRM$8i7SHKiU1N6ZPdfQlU5ybqJXoCTalAufoiYWWTv0ejM=", "last_login": "2021-09-14T14:04:45.688Z", "is_superuser": false, "username": "migration1", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-08-27T15:27:00Z", "groups": [2], "user_permissions": []}}, {"model": "auth.user", "pk": 5, "fields": {"password": "pbkdf2_sha256$260000$Ps6lNmwTNp32rHq7oCO9QF$GOebLa2Zx0Jp2LvL9ISomn+tzDCX3E0BU8vpPS/qSwo=", "last_login": "2021-09-14T13:40:29.277Z", "is_superuser": false, "username": "migration2", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-08-27T15:27:08Z", "groups": [2], "user_permissions": []}}, {"model": "auth.user", "pk": 6, "fields": {"password": "pbkdf2_sha256$260000$KWMZsotGHfClKR7v6t5kCn$uUJgBWIQieWUMdtPUXVvAaae06qLmCdKEYGT/1dWcYM=", "last_login": "2021-09-14T22:25:07.943Z", "is_superuser": false, "username": "manager1", "first_name": "", "last_name": "", "email": "", "is_staff": true, "is_active": true, "date_joined": "2021-08-27T15:27:16Z", "groups": [3], "user_permissions": []}}, {"model": "auth.user", "pk": 7, "fields": {"password": "pbkdf2_sha256$260000$Qa4tdhycurgmOrIMnGcOsc$7tlzyqCsv5CO19uQLhMXuBVq90K9/nRxQIKoM2uYcbQ=", "last_login": null, "is_superuser": false, "username": "manager2", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-08-27T15:27:31Z", "groups": [3], "user_permissions": []}}, {"model": "auth.user", "pk": 8, "fields": {"password": "pbkdf2_sha256$260000$Rk5A5ejNCT3eH5MuS7mdNQ$JGFCDZMJMRhAooMA3+hR8m834zQCFh0kgzZXWNI1GDQ=", "last_login": "2021-09-14T13:08:23.113Z", "is_superuser": false, "username": "migration3", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-09-14T13:08:14.509Z", "groups": [], "user_permissions": []}}, {"model": "auth.user", "pk": 9, "fields": {"password": "pbkdf2_sha256$260000$NT9OReetFbBHhwJTGNDMkB$6TemneVNPTW8WqnK+VrDLoEThMHqGlWl7v+DFJMmmMk=", "last_login": "2021-09-14T22:33:06.087Z", "is_superuser": false, "username": "quality1", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-09-14T22:32:10Z", "groups": [4], "user_permissions": []}}, {"model": "auth.user", "pk": 10, "fields": {"password": "pbkdf2_sha256$260000$fBtq2ygD72U2fXZQvcqLF7$5HVIRLyYPXOmf5t6bqkpzEBA7w1MHNYt14G9rJdxtSA=", "last_login": null, "is_superuser": false, "username": "quality2", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-09-14T22:32:27Z", "groups": [4], "user_permissions": []}}] \ No newline at end of file diff --git a/spf/core/forms.py b/spf/core/forms.py deleted file mode 100644 index 9b8bfef..0000000 --- a/spf/core/forms.py +++ /dev/null @@ -1,53 +0,0 @@ -from django.forms import TextInput, EmailInput -from django.contrib.auth.forms import UserCreationForm, UserChangeForm -from django.contrib.auth.models import User -from django.utils.translation import gettext as _ - - -class CreateUserForm(UserCreationForm): - class Meta: - model = User - fields = ['username', 'email', 'first_name', 'last_name', 'password1', 'password2'] - widgets = { - 'username': TextInput(attrs={ - 'class': 'form-control', - 'placeholder': _('Enter your username') - }), - 'email': EmailInput(attrs={ - 'class': 'form-control', - 'placeholder': _('Enter your e-mail') - }), - 'first_name': TextInput(attrs={ - 'class': 'form-control', - 'placeholder': _('Enter your first name') - }), - 'last_name': TextInput(attrs={ - 'class': 'form-control', - 'placeholder': _('Enter your last name') - }), - } - - -class UpdateUserForm(UserChangeForm): - class Meta: - model = User - fields = ['username', 'email', 'first_name', 'last_name'] - widgets = { - 'username': TextInput(attrs={ - 'class': 'form-control', - 'placeholder': _('Enter your username'), - 'readonly': True - }), - 'email': EmailInput(attrs={ - 'class': 'form-control', - 'placeholder': _('Enter your e-mail') - }), - 'first_name': TextInput(attrs={ - 'class': 'form-control', - 'placeholder': _('Enter your first name') - }), - 'last_name': TextInput(attrs={ - 'class': 'form-control', - 'placeholder': _('Enter your last name') - }), - } diff --git a/spf/core/locale/es/LC_MESSAGES/django.po b/spf/core/locale/es/LC_MESSAGES/django.po deleted file mode 100644 index cb1a883..0000000 --- a/spf/core/locale/es/LC_MESSAGES/django.po +++ /dev/null @@ -1,547 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-09-24 02:18+0000\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: decorators.py:26 decorators.py:30 -msgid "You do not have permission to access the requested page " -msgstr "No tienes permiso para acceder a la página solicitada " - -#: forms.py:14 forms.py:38 templates/accounts/login.html:19 -#: templates/accounts/register.html:19 -msgid "Enter your username" -msgstr "Ingrese su nombre de usuario" - -#: forms.py:18 forms.py:43 -#: templates/accounts/password_reset/password_reset.html:18 -#: templates/accounts/register.html:23 templates/core/user_profile_edit.html:22 -msgid "Enter your e-mail" -msgstr "Ingrese su correo electrónico" - -#: forms.py:22 forms.py:47 templates/accounts/register.html:27 -#: templates/core/user_profile_edit.html:26 -msgid "Enter your first name" -msgstr "Ingrese su nombre" - -#: forms.py:26 forms.py:51 templates/accounts/register.html:31 -#: templates/core/user_profile_edit.html:30 -msgid "Enter your last name" -msgstr "Ingrese su nombre de familia" - -#: models.py:16 -msgid "Received" -msgstr "Recebió" - -#: models.py:17 -msgid "Queued for validation" -msgstr "Programado para validación" - -#: models.py:18 -msgid "Validating" -msgstr "Validando" - -#: models.py:19 -msgid "Validation failure" -msgstr "Validación fallida" - -#: models.py:20 -msgid "Validated" -msgstr "Validado" - -#: models.py:34 -msgid "Initiated" -msgstr "Empezado" - -#: models.py:35 -msgid "Completed" -msgstr "Terminado" - -#: models.py:36 -msgid "Failed" -msgstr "Fallido" - -#: models.py:39 -msgid "Retrieve package" -msgstr "Recibir paquete" - -#: models.py:40 templates/core/user_package_upload.html:5 -#: templates/core/user_package_upload.html:9 -#: templates/core/user_package_upload.html:18 templates/index.html:41 -msgid "Upload package" -msgstr "Enviar paquete" - -#: models.py:41 -msgid "Start validation" -msgstr "Empezar validación" - -#: models.py:42 -msgid "Finalize validation" -msgstr "Finalizar validación" - -#: models.py:43 -msgid "Change user groups" -msgstr "Cambiar grupos de usuarios" - -#: templates/accounts/add.html:7 templates/accounts/add.html:46 -#: templates/accounts/password_reset/password_reset_complete.html:7 -#: templates/accounts/password_reset/password_reset_confirm.html:7 -#: templates/accounts/password_reset/password_reset_done.html:7 -#: templates/accounts/register.html:41 templates/index.html:82 -msgid "Add user" -msgstr "Agregar usuario" - -#: templates/accounts/add.html:18 templates/accounts/login.html:18 -#: templates/accounts/register.html:18 -#: templates/core/deposited_package_list.html:19 -#: templates/core/event_list.html:20 templates/core/user_groups_edit.html:21 -#: templates/core/user_profile.html:18 templates/core/user_profile_edit.html:17 -msgid "Username" -msgstr "Usuario" - -#: templates/accounts/add.html:19 -msgid "Enter the username" -msgstr "Ingrese el nombre de usuario" - -#: templates/accounts/add.html:23 -msgid "Enter the user e-mail" -msgstr "Introduzca el correo electrónico del usuario" - -#: templates/accounts/add.html:26 templates/accounts/login.html:22 -#: templates/accounts/register.html:34 -msgid "Password" -msgstr "Contraseña" - -#: templates/accounts/add.html:27 -msgid "Enter the user password" -msgstr "Introduzca la contraseña de usuario" - -#: templates/accounts/add.html:30 -msgid "Confirm the password" -msgstr "Confirma la contraseña" - -#: templates/accounts/add.html:31 -msgid "Re-enter the user password" -msgstr "Vuelva a introducir la contraseña de usuario" - -#: templates/accounts/add.html:34 templates/core/user_profile.html:23 -msgid "Groups" -msgstr "Grupos" - -#: templates/accounts/change_password.html:7 -#: templates/accounts/change_password.html:12 -#: templates/accounts/change_password.html:27 templates/base.html:41 -#: templates/index.html:28 -msgid "Change password" -msgstr "Cambiar contraseña" - -#: templates/accounts/change_password.html:16 -msgid "Old password" -msgstr "Contraseña anterior" - -#: templates/accounts/change_password.html:17 -msgid "Enter your old password" -msgstr "Introduzca su contraseña anterior" - -#: templates/accounts/change_password.html:20 -msgid "New password" -msgstr "Nueva contraseña" - -#: templates/accounts/change_password.html:21 -msgid "Enter your new password" -msgstr "Introduzca su nueva contraseña" - -#: templates/accounts/change_password.html:24 -msgid "Confirm new password" -msgstr "Introduzca su nueva contraseña" - -#: templates/accounts/change_password.html:25 -msgid "Re-enter your new password" -msgstr "Vuelva a introducir su nueva contraseña" - -#: templates/accounts/login.html:7 templates/accounts/login.html:25 -#: templates/accounts/register.html:44 templates/base.html:48 -msgid "Login" -msgstr "Iniciar sesión" - -#: templates/accounts/login.html:23 templates/accounts/register.html:35 -msgid "Enter your password" -msgstr "Introduzca su contraseña" - -#: templates/accounts/login.html:27 -msgid "Don't have an account" -msgstr "No tienes una cuenta" - -#: templates/accounts/login.html:27 templates/accounts/register.html:7 -#: templates/base.html:51 -msgid "Sign up" -msgstr "Registrarse" - -#: templates/accounts/password_reset/password_reset.html:7 -#: templates/accounts/password_reset/password_reset.html:12 -msgid "Reset password" -msgstr "Restablecer la contraseña" - -#: templates/accounts/password_reset/password_reset.html:20 -msgid "Send e-mail" -msgstr "Enviar correo electrónico" - -#: templates/accounts/register.html:26 templates/core/user_groups_edit.html:22 -#: templates/core/user_profile.html:19 templates/core/user_profile_edit.html:25 -msgid "First name" -msgstr "Nombre" - -#: templates/accounts/register.html:30 templates/core/user_groups_edit.html:23 -#: templates/core/user_profile.html:20 templates/core/user_profile_edit.html:29 -msgid "Last name" -msgstr "Nombre de familia" - -#: templates/accounts/register.html:38 -msgid "Confirm your password" -msgstr "Introduzca su contraseña" - -#: templates/accounts/register.html:39 -msgid "Re-enter your password" -msgstr "Vuelva a introducir su contraseña" - -#: templates/accounts/register.html:44 -msgid "Already have an account" -msgstr "Ya tengo una cuenta" - -#: templates/base.html:26 templates/core/journal_list.html:5 -#: templates/core/journal_list.html:9 -msgid "Journals" -msgstr "Revistas" - -#: templates/base.html:38 templates/core/event_list.html:6 -#: templates/core/event_list.html:10 templates/index.html:19 -msgid "Events" -msgstr "Eventos" - -#: templates/base.html:39 templates/core/user_profile.html:6 -#: templates/core/user_profile.html:10 templates/index.html:26 -msgid "Profile" -msgstr "Perfil" - -#: templates/base.html:40 templates/core/user_profile_edit.html:7 -#: templates/core/user_profile_edit.html:11 templates/index.html:27 -msgid "Edit profile" -msgstr "Editar perfil" - -#: templates/base.html:43 -msgid "Logout" -msgstr "Salir" - -#: templates/core/article_files_list.html:5 -#: templates/core/article_files_list.html:9 templates/index.html:70 -msgid "Articles' files" -msgstr "Archivos de artículos" - -#: templates/core/article_files_list.html:18 -msgid "Identifier" -msgstr "Identificador" - -#: templates/core/article_files_list.html:19 -#: templates/core/user_package_download.html:41 -msgid "Creation date" -msgstr "Fecha de criación" - -#: templates/core/article_files_list.html:20 -#: templates/core/user_package_download.html:42 -msgid "Update date" -msgstr "Fecha de actualización" - -#: templates/core/article_files_list.html:21 -#: templates/core/deposited_package_list.html:20 -#: templates/core/user_package_download.html:39 -msgid "Package name" -msgstr "Nombre del paquete" - -#: templates/core/article_files_list.html:22 -msgid "XML" -msgstr "" - -#: templates/core/article_files_list.html:23 -msgid "Assets" -msgstr "" - -#: templates/core/article_files_list.html:24 -msgid "Renditions" -msgstr "" - -#: templates/core/article_files_list.html:54 -#: templates/core/deposited_package_list.html:45 -#: templates/core/event_list.html:55 templates/core/journal_list.html:46 -#: templates/core/user_groups_edit.html:63 -msgid "First" -msgstr "Primero" - -#: templates/core/article_files_list.html:58 -#: templates/core/deposited_package_list.html:49 -#: templates/core/event_list.html:59 templates/core/journal_list.html:50 -#: templates/core/user_groups_edit.html:67 -msgid "Previous" -msgstr "Anterior" - -#: templates/core/article_files_list.html:63 -#: templates/core/deposited_package_list.html:54 -#: templates/core/event_list.html:64 templates/core/journal_list.html:55 -#: templates/core/user_groups_edit.html:72 -msgid "Page" -msgstr "Página" - -#: templates/core/article_files_list.html:63 -#: templates/core/deposited_package_list.html:54 -#: templates/core/event_list.html:64 templates/core/journal_list.html:55 -#: templates/core/user_groups_edit.html:72 -msgid "of" -msgstr "de" - -#: templates/core/article_files_list.html:68 -#: templates/core/deposited_package_list.html:59 -#: templates/core/event_list.html:69 templates/core/journal_list.html:60 -#: templates/core/user_groups_edit.html:77 -msgid "Next" -msgstr "Seguiente" - -#: templates/core/article_files_list.html:71 -#: templates/core/deposited_package_list.html:62 -#: templates/core/event_list.html:72 templates/core/journal_list.html:63 -#: templates/core/user_groups_edit.html:80 -msgid "Last" -msgstr "Último" - -#: templates/core/deposited_package_list.html:6 -#: templates/core/deposited_package_list.html:10 templates/index.html:21 -msgid "Deposited packages" -msgstr "Fecha de deposito" - -#: templates/core/deposited_package_list.html:21 -msgid "Datetime" -msgstr "Fecha y hora" - -#: templates/core/deposited_package_list.html:22 -#: templates/core/event_list.html:24 -msgid "Status" -msgstr "Estado" - -#: templates/core/event_list.html:22 -msgid "Activity" -msgstr "Actividad" - -#: templates/core/event_list.html:23 -msgid "Annotation" -msgstr "Anotación" - -#: templates/core/event_list.html:25 -msgid "Timestamp" -msgstr "Fecha y hora" - -#: templates/core/journal_list.html:18 -msgid "Title" -msgstr "Título" - -#: templates/core/journal_list.html:19 -msgid "Short title" -msgstr "Título corto" - -#: templates/core/journal_list.html:20 -msgid "Acronym" -msgstr "Acrónimo" - -#: templates/core/journal_list.html:21 -msgid "Print ISSN" -msgstr "Print ISSN" - -#: templates/core/journal_list.html:22 -msgid "Online ISSN" -msgstr "Online ISSN" - -#: templates/core/user_groups_edit.html:6 -#: templates/core/user_groups_edit.html:10 templates/index.html:83 -msgid "User groups" -msgstr "Grupos de usuarios" - -#: templates/core/user_groups_edit.html:24 templates/core/user_profile.html:21 -msgid "E-mail" -msgstr "E-mail" - -#: templates/core/user_groups_edit.html:54 -msgid "Update users' groups" -msgstr "Actualizar grupos de usuarios" - -#: templates/core/user_package_download.html:6 -#: templates/core/user_package_download.html:10 -#: templates/core/user_package_download.html:16 templates/index.html:40 -msgid "Search package" -msgstr "Buscar paquete" - -#: templates/core/user_package_download.html:22 -msgid "Document identifier" -msgstr "Identificador de documento" - -#: templates/core/user_package_download.html:23 -msgid "Enter a document identifier" -msgstr "Ingrese un identificador de documento " - -#: templates/core/user_package_download.html:25 -msgid "Search" -msgstr "Buscar" - -#: templates/core/user_package_download.html:33 -msgid "Results for document" -msgstr "Resultados del documento" - -#: templates/core/user_package_download.html:40 -#, fuzzy -#| msgid "Packages" -msgid "Package address" -msgstr "Direción del paquete" - -#: templates/core/user_package_upload.html:21 -msgid "Upload" -msgstr "Cargar" - -#: templates/core/user_profile.html:15 -msgid "User profile" -msgstr "Perfil del usuario" - -#: templates/core/user_profile.html:22 -msgid "Last login date" -msgstr "Última fecha de inicio de sesión" - -#: templates/core/user_profile_edit.html:32 -msgid "Update user" -msgstr "Actualizar usuario" - -#: templates/faq.html:5 templates/faq.html:10 -msgid "Frequently asked questions" -msgstr "Preguntas más frecuentes" - -#: templates/index.html:10 -msgid "Home" -msgstr "Inicio" - -#: templates/index.html:16 -msgid "My space" -msgstr "Mi spacio" - -#: templates/index.html:24 -msgid "Migrated data" -msgstr "Datos migrados" - -#: templates/index.html:37 -msgid "Ingress" -msgstr "Entrada" - -#: templates/index.html:51 -msgid "Migration" -msgstr "Migración" - -#: templates/index.html:54 -msgid "Migrate title" -msgstr "Migrar título" - -#: templates/index.html:55 -msgid "Migrate fascicle" -msgstr "Migrar asunto" - -#: templates/index.html:56 -msgid "Migrate document" -msgstr "Migrar documento" - -#: templates/index.html:66 -msgid "Package management" -msgstr "Gestión de paquetes" - -#: templates/index.html:69 -msgid "All deposited packages" -msgstr "Todos los paquetes depositados" - -#: templates/index.html:78 -msgid "User management" -msgstr "Gestión de usuarios" - -#: templates/index.html:81 -msgid "All events" -msgstr "Todos los eventos" - -#: templatetags/spf_extras.py:29 -msgid "Q. Analyst" -msgstr "An. de Calidad" - -#: templatetags/spf_extras.py:31 -msgid "Op. Ingress" -msgstr "Op. de Entrada" - -#: templatetags/spf_extras.py:33 -msgid "Op. Migration" -msgstr "Op. de Migración" - -#: templatetags/spf_extras.py:35 -msgid "Manager" -msgstr "Gerente" - -#: views.py:41 -#, python-format -msgid "User %s was updated" -msgstr "Se creó el usuario %s" - -#: views.py:67 views.py:151 -#, python-format -msgid "User %s was created" -msgstr "Se creó el usuario %s" - -#: views.py:97 -msgid "Incorrect username or password" -msgstr "Nombre de usuario o contraseña incorrecta." - -#: views.py:114 -msgid "Your password was updated" -msgstr "Su contraseña ha sido actualizada" - -#: views.py:233 -#, python-format -msgid "Errors ocurred: %s" -msgstr "Ocurrieron errores: %s" - -#: views.py:240 -#, python-format -msgid "Package (%(name)s, %(id)s) was added" -msgstr "Se agregó el paquete (%(name)s, %(id)s)" - -#: views.py:250 -msgid " does not have a valid format. Please provide a zip file." -msgstr " no tiene un formato válido. Por favor, proporcione un archivo zip." - -#: views.py:280 -#, python-format -msgid "No packages were found for document %s" -msgstr "No se encontraron paquetes para el documento %s" - -#: views.py:306 -msgid "Users' groups were updated" -msgstr "Se actualizaron los grupos de usuarios" - -#~ msgid "Activities" -#~ msgstr "Actividades" - -#~ msgid "All activities" -#~ msgstr "Todas las actividades" - -#~ msgid "The two password fields didn’t match." -#~ msgstr "Los dos campos de contraseña no coincidían." diff --git a/spf/core/locale/pt/LC_MESSAGES/django.po b/spf/core/locale/pt/LC_MESSAGES/django.po deleted file mode 100644 index bac2988..0000000 --- a/spf/core/locale/pt/LC_MESSAGES/django.po +++ /dev/null @@ -1,546 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-09-24 02:18+0000\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: decorators.py:26 decorators.py:30 -msgid "You do not have permission to access the requested page " -msgstr "Você não possui permissão para acessar a página requisitada " - -#: forms.py:14 forms.py:38 templates/accounts/login.html:19 -#: templates/accounts/register.html:19 -msgid "Enter your username" -msgstr "Digite seu nome de usuário" - -#: forms.py:18 forms.py:43 -#: templates/accounts/password_reset/password_reset.html:18 -#: templates/accounts/register.html:23 templates/core/user_profile_edit.html:22 -msgid "Enter your e-mail" -msgstr "Digite seu e-mail" - -#: forms.py:22 forms.py:47 templates/accounts/register.html:27 -#: templates/core/user_profile_edit.html:26 -msgid "Enter your first name" -msgstr "Digite seu nome" - -#: forms.py:26 forms.py:51 templates/accounts/register.html:31 -#: templates/core/user_profile_edit.html:30 -msgid "Enter your last name" -msgstr "Digite seu sobrenome" - -#: models.py:16 -msgid "Received" -msgstr "Recebido" - -#: models.py:17 -msgid "Queued for validation" -msgstr "Agendado para validação" - -#: models.py:18 -msgid "Validating" -msgstr "Validando" - -#: models.py:19 -msgid "Validation failure" -msgstr "Validação falhou" - -#: models.py:20 -msgid "Validated" -msgstr "Validado" - -#: models.py:34 -msgid "Initiated" -msgstr "Iniciado" - -#: models.py:35 -msgid "Completed" -msgstr "Completado" - -#: models.py:36 -msgid "Failed" -msgstr "Falhou" - -#: models.py:39 -msgid "Retrieve package" -msgstr "Procurar pacote" - -#: models.py:40 templates/core/user_package_upload.html:5 -#: templates/core/user_package_upload.html:9 -#: templates/core/user_package_upload.html:18 templates/index.html:41 -msgid "Upload package" -msgstr "Enviar pacote" - -#: models.py:41 -msgid "Start validation" -msgstr "Iniciar validação" - -#: models.py:42 -msgid "Finalize validation" -msgstr "Finalizar validação" - -#: models.py:43 -msgid "Change user groups" -msgstr "Alterar grupos de usuários" - -#: templates/accounts/add.html:7 templates/accounts/add.html:46 -#: templates/accounts/password_reset/password_reset_complete.html:7 -#: templates/accounts/password_reset/password_reset_confirm.html:7 -#: templates/accounts/password_reset/password_reset_done.html:7 -#: templates/accounts/register.html:41 templates/index.html:82 -msgid "Add user" -msgstr "Adicionar usuário" - -#: templates/accounts/add.html:18 templates/accounts/login.html:18 -#: templates/accounts/register.html:18 -#: templates/core/deposited_package_list.html:19 -#: templates/core/event_list.html:20 templates/core/user_groups_edit.html:21 -#: templates/core/user_profile.html:18 templates/core/user_profile_edit.html:17 -msgid "Username" -msgstr "Usuário" - -#: templates/accounts/add.html:19 -msgid "Enter the username" -msgstr "Digite o nome de usuário" - -#: templates/accounts/add.html:23 -msgid "Enter the user e-mail" -msgstr "Digite o e-mail" - -#: templates/accounts/add.html:26 templates/accounts/login.html:22 -#: templates/accounts/register.html:34 -msgid "Password" -msgstr "Senha" - -#: templates/accounts/add.html:27 -msgid "Enter the user password" -msgstr "Digite a senha" - -#: templates/accounts/add.html:30 -msgid "Confirm the password" -msgstr "Confirme a senha" - -#: templates/accounts/add.html:31 -msgid "Re-enter the user password" -msgstr "Digita a senha novamente" - -#: templates/accounts/add.html:34 templates/core/user_profile.html:23 -msgid "Groups" -msgstr "Grupos" - -#: templates/accounts/change_password.html:7 -#: templates/accounts/change_password.html:12 -#: templates/accounts/change_password.html:27 templates/base.html:41 -#: templates/index.html:28 -msgid "Change password" -msgstr "Alterar senha" - -#: templates/accounts/change_password.html:16 -msgid "Old password" -msgstr "Senha antiga" - -#: templates/accounts/change_password.html:17 -msgid "Enter your old password" -msgstr "Digite sua senha antiga" - -#: templates/accounts/change_password.html:20 -msgid "New password" -msgstr "Senha nova" - -#: templates/accounts/change_password.html:21 -msgid "Enter your new password" -msgstr "Digita sua senha nova" - -#: templates/accounts/change_password.html:24 -msgid "Confirm new password" -msgstr "Confirme sua senha nova" - -#: templates/accounts/change_password.html:25 -msgid "Re-enter your new password" -msgstr "Digite sua senha nova novamente" - -#: templates/accounts/login.html:7 templates/accounts/login.html:25 -#: templates/accounts/register.html:44 templates/base.html:48 -msgid "Login" -msgstr "Entrar" - -#: templates/accounts/login.html:23 templates/accounts/register.html:35 -msgid "Enter your password" -msgstr "Digite sua senha" - -#: templates/accounts/login.html:27 -msgid "Don't have an account" -msgstr "Não possui uma conta" - -#: templates/accounts/login.html:27 templates/accounts/register.html:7 -#: templates/base.html:51 -msgid "Sign up" -msgstr "Registrar-se" - -#: templates/accounts/password_reset/password_reset.html:7 -#: templates/accounts/password_reset/password_reset.html:12 -msgid "Reset password" -msgstr "Redefinir senha" - -#: templates/accounts/password_reset/password_reset.html:20 -msgid "Send e-mail" -msgstr "Enviar e-mail" - -#: templates/accounts/register.html:26 templates/core/user_groups_edit.html:22 -#: templates/core/user_profile.html:19 templates/core/user_profile_edit.html:25 -msgid "First name" -msgstr "Nome" - -#: templates/accounts/register.html:30 templates/core/user_groups_edit.html:23 -#: templates/core/user_profile.html:20 templates/core/user_profile_edit.html:29 -msgid "Last name" -msgstr "Sobrenome" - -#: templates/accounts/register.html:38 -msgid "Confirm your password" -msgstr "Confirme sua senha" - -#: templates/accounts/register.html:39 -msgid "Re-enter your password" -msgstr "Digite sua senha novamente" - -#: templates/accounts/register.html:44 -msgid "Already have an account" -msgstr "Já possui uma conta" - -#: templates/base.html:26 templates/core/journal_list.html:5 -#: templates/core/journal_list.html:9 -msgid "Journals" -msgstr "Periódicos" - -#: templates/base.html:38 templates/core/event_list.html:6 -#: templates/core/event_list.html:10 templates/index.html:19 -msgid "Events" -msgstr "Ações" - -#: templates/base.html:39 templates/core/user_profile.html:6 -#: templates/core/user_profile.html:10 templates/index.html:26 -msgid "Profile" -msgstr "Perfil" - -#: templates/base.html:40 templates/core/user_profile_edit.html:7 -#: templates/core/user_profile_edit.html:11 templates/index.html:27 -msgid "Edit profile" -msgstr "Editar perfil" - -#: templates/base.html:43 -msgid "Logout" -msgstr "Sair" - -#: templates/core/article_files_list.html:5 -#: templates/core/article_files_list.html:9 templates/index.html:70 -msgid "Articles' files" -msgstr "Arquivos de artigos" - -#: templates/core/article_files_list.html:18 -msgid "Identifier" -msgstr "Identificador de documento" - -#: templates/core/article_files_list.html:19 -#: templates/core/user_package_download.html:41 -msgid "Creation date" -msgstr "Data de criação" - -#: templates/core/article_files_list.html:20 -#: templates/core/user_package_download.html:42 -msgid "Update date" -msgstr "Data de atualização" - -#: templates/core/article_files_list.html:21 -#: templates/core/deposited_package_list.html:20 -#: templates/core/user_package_download.html:39 -msgid "Package name" -msgstr "Nome do pacote" - -#: templates/core/article_files_list.html:22 -msgid "XML" -msgstr "" - -#: templates/core/article_files_list.html:23 -msgid "Assets" -msgstr "" - -#: templates/core/article_files_list.html:24 -msgid "Renditions" -msgstr "" - -#: templates/core/article_files_list.html:54 -#: templates/core/deposited_package_list.html:45 -#: templates/core/event_list.html:55 templates/core/journal_list.html:46 -#: templates/core/user_groups_edit.html:63 -msgid "First" -msgstr "Primeiro" - -#: templates/core/article_files_list.html:58 -#: templates/core/deposited_package_list.html:49 -#: templates/core/event_list.html:59 templates/core/journal_list.html:50 -#: templates/core/user_groups_edit.html:67 -msgid "Previous" -msgstr "Anterior" - -#: templates/core/article_files_list.html:63 -#: templates/core/deposited_package_list.html:54 -#: templates/core/event_list.html:64 templates/core/journal_list.html:55 -#: templates/core/user_groups_edit.html:72 -msgid "Page" -msgstr "Página" - -#: templates/core/article_files_list.html:63 -#: templates/core/deposited_package_list.html:54 -#: templates/core/event_list.html:64 templates/core/journal_list.html:55 -#: templates/core/user_groups_edit.html:72 -msgid "of" -msgstr "de" - -#: templates/core/article_files_list.html:68 -#: templates/core/deposited_package_list.html:59 -#: templates/core/event_list.html:69 templates/core/journal_list.html:60 -#: templates/core/user_groups_edit.html:77 -msgid "Next" -msgstr "Próximo" - -#: templates/core/article_files_list.html:71 -#: templates/core/deposited_package_list.html:62 -#: templates/core/event_list.html:72 templates/core/journal_list.html:63 -#: templates/core/user_groups_edit.html:80 -msgid "Last" -msgstr "Último" - -#: templates/core/deposited_package_list.html:6 -#: templates/core/deposited_package_list.html:10 templates/index.html:21 -msgid "Deposited packages" -msgstr "Pacotes depositados" - -#: templates/core/deposited_package_list.html:21 -msgid "Datetime" -msgstr "Data e hora" - -#: templates/core/deposited_package_list.html:22 -#: templates/core/event_list.html:24 -msgid "Status" -msgstr "Estado" - -#: templates/core/event_list.html:22 -msgid "Activity" -msgstr "Atividade" - -#: templates/core/event_list.html:23 -msgid "Annotation" -msgstr "Anotação" - -#: templates/core/event_list.html:25 -msgid "Timestamp" -msgstr "Data e hora" - -#: templates/core/journal_list.html:18 -msgid "Title" -msgstr "Título" - -#: templates/core/journal_list.html:19 -msgid "Short title" -msgstr "Título abreviado" - -#: templates/core/journal_list.html:20 -msgid "Acronym" -msgstr "Acrônimo" - -#: templates/core/journal_list.html:21 -msgid "Print ISSN" -msgstr "Print ISSN" - -#: templates/core/journal_list.html:22 -msgid "Online ISSN" -msgstr "Online ISSN" - -#: templates/core/user_groups_edit.html:6 -#: templates/core/user_groups_edit.html:10 templates/index.html:83 -msgid "User groups" -msgstr "Grupos de usuário" - -#: templates/core/user_groups_edit.html:24 templates/core/user_profile.html:21 -msgid "E-mail" -msgstr "E-mail" - -#: templates/core/user_groups_edit.html:54 -msgid "Update users' groups" -msgstr "Atualizar grupos de usuários" - -#: templates/core/user_package_download.html:6 -#: templates/core/user_package_download.html:10 -#: templates/core/user_package_download.html:16 templates/index.html:40 -msgid "Search package" -msgstr "Procurar pacote" - -#: templates/core/user_package_download.html:22 -msgid "Document identifier" -msgstr "Identificador de documento" - -#: templates/core/user_package_download.html:23 -msgid "Enter a document identifier" -msgstr "Digite um identificador de documento" - -#: templates/core/user_package_download.html:25 -msgid "Search" -msgstr "Procurar" - -#: templates/core/user_package_download.html:33 -msgid "Results for document" -msgstr "Resultados para o documento" - -#: templates/core/user_package_download.html:40 -msgid "Package address" -msgstr "Endereço do pacote" - -#: templates/core/user_package_upload.html:21 -msgid "Upload" -msgstr "Enviar" - -#: templates/core/user_profile.html:15 -msgid "User profile" -msgstr "Editar perfil" - -#: templates/core/user_profile.html:22 -msgid "Last login date" -msgstr "Data do último acesso" - -#: templates/core/user_profile_edit.html:32 -msgid "Update user" -msgstr "Atualizar usuário" - -#: templates/faq.html:5 templates/faq.html:10 -msgid "Frequently asked questions" -msgstr "Perguntas frequentes" - -#: templates/index.html:10 -msgid "Home" -msgstr "Início" - -#: templates/index.html:16 -msgid "My space" -msgstr "Meu espaço" - -#: templates/index.html:24 -msgid "Migrated data" -msgstr "Dados migrados" - -#: templates/index.html:37 -msgid "Ingress" -msgstr "Ingresso" - -#: templates/index.html:51 -msgid "Migration" -msgstr "Migração" - -#: templates/index.html:54 -msgid "Migrate title" -msgstr "Migrar periódico" - -#: templates/index.html:55 -msgid "Migrate fascicle" -msgstr "Migrar fascículo" - -#: templates/index.html:56 -msgid "Migrate document" -msgstr "Migrar artigo" - -#: templates/index.html:66 -msgid "Package management" -msgstr "Gerenciamento de pacotes" - -#: templates/index.html:69 -msgid "All deposited packages" -msgstr "Todo os pacotes depositados" - -#: templates/index.html:78 -msgid "User management" -msgstr "Gerenciamento de usuário" - -#: templates/index.html:81 -msgid "All events" -msgstr "Todas as ações" - -#: templatetags/spf_extras.py:29 -msgid "Q. Analyst" -msgstr "An. de Qualidade" - -#: templatetags/spf_extras.py:31 -msgid "Op. Ingress" -msgstr "Op. de Ingresso" - -#: templatetags/spf_extras.py:33 -msgid "Op. Migration" -msgstr "Op. de Migração" - -#: templatetags/spf_extras.py:35 -msgid "Manager" -msgstr "Gerente" - -#: views.py:41 -#, python-format -msgid "User %s was updated" -msgstr "Usuário %s foi atualizado" - -#: views.py:67 views.py:151 -#, python-format -msgid "User %s was created" -msgstr "Usuário %s foi criado" - -#: views.py:97 -msgid "Incorrect username or password" -msgstr "Nome de usuário ou senha incorreto" - -#: views.py:114 -msgid "Your password was updated" -msgstr "Sua senha foi atualizada" - -#: views.py:233 -#, python-format -msgid "Errors ocurred: %s" -msgstr "Ocorreram erros: %s" - -#: views.py:240 -#, python-format -msgid "Package (%(name)s, %(id)s) was added" -msgstr "Pacote (%(name)s, %(id)s) foi adicionado" - -#: views.py:250 -msgid " does not have a valid format. Please provide a zip file." -msgstr "" -" não possui um formato válido. Por favor, forneça um arquivo em formato zip." - -#: views.py:280 -#, python-format -msgid "No packages were found for document %s" -msgstr "Não foram encontrados pacotes para o documento %s" - -#: views.py:306 -msgid "Users' groups were updated" -msgstr "Grupos de usuários foram atualizados" - -#~ msgid "Activities" -#~ msgstr "Atividades" - -#~ msgid "All activities" -#~ msgstr "Todas as atividades" - -#~ msgid "The two password fields didn’t match." -#~ msgstr "As duas senhas são diferentes." diff --git a/spf/core/management/commands/make_messages_no_fuzzy.py b/spf/core/management/commands/make_messages_no_fuzzy.py deleted file mode 100644 index 0e46501..0000000 --- a/spf/core/management/commands/make_messages_no_fuzzy.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.core.management.commands import makemessages - - -class Command(makemessages.Command): - msgmerge_options = ['-q', '--previous', '--no-fuzzy-matching'] diff --git a/spf/core/migrations/__init__.py b/spf/core/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/spf/core/models.py b/spf/core/models.py deleted file mode 100644 index d50e325..0000000 --- a/spf/core/models.py +++ /dev/null @@ -1,67 +0,0 @@ -from django.db import models -from django.contrib.auth.models import User -from django.utils.translation import gettext_lazy as _ - - -GROUP_MANAGER = 'manager' -GROUP_OPERATOR_INGRESS = 'operator_ingress' -GROUP_OPERATOR_MIGRATION = 'operator_migration' -GROUP_QUALITY_ANALYST = 'quality_analyst' - -SCOPE_ALL_USERS = 'all_users' - - -class IngressPackage(models.Model): - class Status(models.TextChoices): - RECEIVED = 'R', _('Received') - QUEUDED_FOR_VALIDATION = 'Q', _('Queued for validation') - VALIDATING = 'D', _('Validating') - VALIDATION_FAILURE = 'F', _('Validation failure') - VALIDATED = 'V', _('Validated') - - user = models.ForeignKey(User, on_delete=models.PROTECT) - package_name = models.CharField(max_length=200) - datetime = models.DateTimeField() - status = models.CharField(max_length=1, choices=Status.choices, blank=False, null=False) - - -class MigratePackage(models.Model): - ... - - -class Event(models.Model): - class Status(models.TextChoices): - INITIATED = 'I', _('Initiated') - COMPLETED = 'C', _('Completed') - FAILED = 'F', _('Failed') - - class Name(models.TextChoices): - RETRIEVE_PACKAGE = 'RP', _('Retrieve package') - UPLOAD_PACKAGE = 'UP', _('Upload package') - START_VALIDATION = 'SV', _('Start validation') - FINALIZE_VALIDATION = 'FV', _('Finalize validation') - CHANGE_USER_GROUPS = 'CUG', _('Change user groups') - - # quem realiza o evento - user = models.ForeignKey(User, on_delete=models.PROTECT) - - # momento em que o evento foi iniciado - datetime = models.DateTimeField(auto_now=True) - - # nome do evento - name = models.CharField(max_length=3, choices=Name.choices, blank=False, null=False) - - # estado do evento (iniciado, realizando, concluído) - status = models.CharField(max_length=1, choices=Status.choices, blank=False, null=False) - - # informação relacionada ao evento - annotation = models.CharField(max_length=200, null=True) - - -class ValidationSchema(models.Model): - schema_name = models.CharField(max_length=200, null=True) - - -class Validation(models.Model): - name = models.CharField(max_length=200, null=True) - validation_schema = models.ForeignKey(ValidationSchema, on_delete=models.PROTECT) diff --git a/spf/core/static/css/style.css b/spf/core/static/css/style.css deleted file mode 100644 index 5bbfb99..0000000 --- a/spf/core/static/css/style.css +++ /dev/null @@ -1,10 +0,0 @@ -.form-user { - width: 100%; - max-width: 400px; - padding: 0; - margin: 0 auto; -} - -.is-no-rounded { - border-radius: 0; -} diff --git a/spf/core/static/img/logo-scielo.svg b/spf/core/static/img/logo-scielo.svg deleted file mode 100644 index 672fc14..0000000 --- a/spf/core/static/img/logo-scielo.svg +++ /dev/null @@ -1 +0,0 @@ -logo-scielo-portal-no-label-2 \ No newline at end of file diff --git a/spf/core/tasks.py b/spf/core/tasks.py deleted file mode 100644 index 61ac65a..0000000 --- a/spf/core/tasks.py +++ /dev/null @@ -1,19 +0,0 @@ -from celery import shared_task, current_task - -import dsm.ingress as dsm_ingress - - -@shared_task -def task_get_package_uri_by_pid(pid): - result = dsm_ingress.get_package_uri_by_pid(pid) - - current_task.update_state( - state='PROGRESS', - meta={ - 'status': 'LOADING...', - }) - - return result - - - diff --git a/spf/core/templates/base.html b/spf/core/templates/base.html deleted file mode 100644 index 087b995..0000000 --- a/spf/core/templates/base.html +++ /dev/null @@ -1,80 +0,0 @@ - - -{% load i18n %} - - {% load static %} - {% block title %}{% endblock %} - - - - - - - - - - - - - -
-{% for message in messages %} - -{% endfor %} -
- -
- {% block content %} - {% endblock %} -
- - \ No newline at end of file diff --git a/spf/core/templates/faq.html b/spf/core/templates/faq.html deleted file mode 100644 index c8ff3a9..0000000 --- a/spf/core/templates/faq.html +++ /dev/null @@ -1,12 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} - -{% block title %} -SciELO Publishing Framework - {% trans 'Frequently asked questions' %} -{% endblock %} - -{% block content %} -
-

{% trans 'Frequently asked questions' %}

-
-{% endblock %} diff --git a/spf/core/templates/index.html b/spf/core/templates/index.html deleted file mode 100644 index 69d4773..0000000 --- a/spf/core/templates/index.html +++ /dev/null @@ -1,109 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% load spf_extras %} - -{% block title %} -SciELO Publishing Framework - Home -{% endblock %} - -{% block content %} -

{% trans 'Home' %}

- {% if user.is_authenticated %} -
-
-
-
- {% trans 'My space' %} -
-
- {% trans 'Events' %} - {% if user.is_superuser or user|has_group:"manager" or user|has_group:"operator_ingress" %} - {% trans "Deposited packages" %} - {% endif %} - {% if user.is_superuser or user|has_group:"manager" or user|has_group:"operator_migration" %} - {% trans "Migrated data" %} - {% endif %} - {% trans 'Profile' %} - {% trans 'Edit profile' %} - {% trans 'Change password' %} -
-
-
- - {% if user.is_superuser or user|has_group:"manager" or user|has_group:"operator_ingress" %} -
-
-
- {% trans 'Ingress' %} -
- -
-
- - - - {% endif %} - - {% if user.is_superuser or user|has_group:"manager" or user|has_group:"operator_migration" %} - - {% endif %} - - {% if user.is_superuser or user|has_group:"manager" %} -
-
-
- {% trans 'Package management' %} -
- -
-
- -
-
-
- {% trans 'User management' %} -
- -
-
- {% endif %} - -
- {% endif %} - -{% endblock %} diff --git a/spf/core/templates/ingress/article_files_list.html b/spf/core/templates/ingress/article_files_list.html deleted file mode 100644 index 4a9f84b..0000000 --- a/spf/core/templates/ingress/article_files_list.html +++ /dev/null @@ -1,79 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} - -{% block title %} -SciELO Publishing Framework - {% trans "Articles' files" %} -{% endblock %} - -{% block content %} -

{% trans "Articles' files" %}

- -
- {% if article_files_obj %} -
- - - - - - - - - - - - - - - {% for art in article_files_obj %} - - - - - {% if art.created != art.updated %} - - {% else %} - - {% endif %} - - - - - - {% endfor %} - -
#{% trans 'Identifier' %}{% trans 'Creation date' %}{% trans 'Update date' %}{% trans 'Package name' %}{% trans 'XML' %}{% trans 'Assets' %}{% trans 'Renditions' %}
{{ article_files_obj.start_index|add:forloop.counter0 }}{{ art.id }}{{ art.created|date:'Y-m-d H:i' }}{{ art.updated|date:'Y-m-d H:i' }}{{ art.file.name }}{{ art.xml }}{{ art.assets|length }}{{ art.renditions|length }}
-
- {% endif %} -
- -{% if article_files_obj %} - -{% endif %} - -{% endblock %} \ No newline at end of file diff --git a/spf/core/templates/ingress/package_list.html b/spf/core/templates/ingress/package_list.html deleted file mode 100644 index 0498a4f..0000000 --- a/spf/core/templates/ingress/package_list.html +++ /dev/null @@ -1,70 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% load spf_extras %} - -{% block title %} -SciELO Publishing Framework - {% trans 'Deposited packages' %} -{% endblock %} - -{% block content %} -

{% trans 'Deposited packages' %}

- -
- {% if deposited_package_obj %} -
- - - - - - - - - - - - {% for dpkg in deposited_package_obj %} - - - - - - - - {% endfor %} - -
#{% trans 'Username' %}{% trans 'Package name' %}{% trans 'Datetime' %}{% trans 'Status' %}
{{ deposited_package_obj.start_index|add:forloop.counter0 }}{{ dpkg.user }}{{ dpkg.package_name }}{{ dpkg.datetime|date:'Y-m-d H:i' }}{{ dpkg.get_status_display }}
-
- {% endif %} -
- -{% if deposited_package_obj %} - -{% endif %} - -{% endblock %} diff --git a/spf/core/templates/ingress/package_upload.html b/spf/core/templates/ingress/package_upload.html deleted file mode 100644 index 14382a7..0000000 --- a/spf/core/templates/ingress/package_upload.html +++ /dev/null @@ -1,28 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} - -{% block title %} -SciELO Publishing Framework - {% trans 'Upload package' %} -{% endblock %} - -{% block content %} -

{% trans 'Upload package' %}

- -
-
-
-
-
- {% csrf_token %} -
- - -
- -
-
-
-
-
- -{% endblock %} \ No newline at end of file diff --git a/spf/core/templates/journal/journal_list.html b/spf/core/templates/journal/journal_list.html deleted file mode 100644 index 83e8827..0000000 --- a/spf/core/templates/journal/journal_list.html +++ /dev/null @@ -1,73 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} - -{% block title %} -SciELO Publishing Framework - {% trans 'Journals' %} -{% endblock %} - -{% block content %} -

{% trans 'Journals' %}

- -
- {% if journal_obj %} -
- - - - - - - - - - - - - - {% for jour in journal_obj %} - - - - - - - - - - {% endfor %} - -
#{% trans 'Title' %}{% trans 'Short title' %}{% trans 'Acronym' %}{% trans 'Print ISSN' %}{% trans 'Online ISSN' %}{% trans 'SciELO ISSN' %}
{{ journal_obj.start_index|add:forloop.counter0 }}{{ jour.title }}{{ jour.short_title }}{{ jour.acronym }}{{ jour.print_issn|default:'' }}{{ jour.eletronic_issn|default:'' }}{{ jour.scielo_issn|default:'' }}
-
- {% endif %} -
- -{% if journal_obj %} - -{% endif %} - -{% endblock %} diff --git a/spf/core/templates/tracking/event_list.html b/spf/core/templates/tracking/event_list.html deleted file mode 100644 index 8b824e6..0000000 --- a/spf/core/templates/tracking/event_list.html +++ /dev/null @@ -1,80 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% load spf_extras %} - -{% block title %} -SciELO Publishing Framework - {% trans 'Events' %} -{% endblock %} - -{% block content %} -

{% trans 'Events' %}

- -
- {% if event_obj %} -
- - - - - {% if user|has_group:"manager" %} - - {% endif %} - - - - - - - - {% for ev in event_obj %} - - - {% if user|has_group:"manager" %} - - {% if ev.annotation %} - - {% else %} - - {% endif %} - - - - {% endfor %} - -
#{% trans 'Username' %}{% trans 'Activity' %}{% trans 'Annotation' %}{% trans 'Status' %}{% trans 'Timestamp' %}
{{ event_obj.start_index|add:forloop.counter0 }}{{ ev.user }} - {% endif %} - {{ ev.get_name_display }}{{ ev.annotation }}{{ ev.get_status_display }}{{ ev.datetime }}
-
- {% endif %} -
- -{% if event_obj %} - -{% endif %} - -{% endblock %} \ No newline at end of file diff --git a/spf/core/templates/user/add.html b/spf/core/templates/user/add.html deleted file mode 100644 index ab2de94..0000000 --- a/spf/core/templates/user/add.html +++ /dev/null @@ -1,49 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% load spf_extras %} -{% load static %} - -{% block title %} -SciELO Publishing Framework - {% trans 'Add user' %} -{% endblock %} - -{% block content %} -
- -
-

SciELO Publishing Framework

-
- {% csrf_token %} -
- - -
-
- - -
-
- - -
-
- - -
-
- - {% for g in available_groups %} -
- {% if g.name not in user_groups %} - - {% else %} - - {% endif %} - -
- {% endfor %} -
- -
- -{% endblock %} diff --git a/spf/core/templates/user/change_password.html b/spf/core/templates/user/change_password.html deleted file mode 100644 index e94cfe3..0000000 --- a/spf/core/templates/user/change_password.html +++ /dev/null @@ -1,31 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% load spf_extras %} -{% load static %} - -{% block title %} -SciELO Publishing Framework - {% trans 'Change password' %} -{% endblock %} - -{% block content %} -
-

{% trans 'Change password' %}

-
- {% csrf_token %} -
- - -
-
- - -
-
- - -
- -
-
- -{% endblock %} diff --git a/spf/core/templates/user/groups_edit.html b/spf/core/templates/user/groups_edit.html deleted file mode 100644 index 248a558..0000000 --- a/spf/core/templates/user/groups_edit.html +++ /dev/null @@ -1,88 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% load spf_extras %} - -{% block title %} -SciELO Publishing Framework - {% trans 'User groups' %} -{% endblock %} - -{% block content %} -

{% trans 'User groups' %}

- -
- {% if user_obj %} -
- {% csrf_token %} -
- - - - - - - - - {% for g in available_groups %} - - {% endfor %} - - - - {% for u in user_obj %} - - - - - - - {% for g in available_groups %} - - {% endfor %} - - {% endfor %} - -
#{% trans 'Username' %}{% trans 'First name' %}{% trans 'Last name' %}{% trans 'E-mail' %}{{ g.name|to_short_group_name }}
{{ user_obj.start_index|add:forloop.counter0 }}{{ u.username }}{{ u.first_name }}{{ u.last_name }}{{ u.email }} -
- {% if u|has_group:g %} - - {% else %} - - {% endif %} -
-
-
- -
- {% endif %} -
- -{% if user_obj %} - -{% endif %} - -{% endblock %} diff --git a/spf/core/templates/user/login.html b/spf/core/templates/user/login.html deleted file mode 100644 index 95cc69b..0000000 --- a/spf/core/templates/user/login.html +++ /dev/null @@ -1,28 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} - -{% load static %} - -{% block title %} -SciELO Publishing Framework - {% trans 'Login' %} -{% endblock %} - -{% block content %} -
- -
-

SciELO Publishing Framework

-
- {% csrf_token %} -
- - -
-
- - -
- -
-

{% trans "Don't have an account" %}?

{% trans 'Sign up' %}.
-{% endblock %} diff --git a/spf/core/templates/user/profile.html b/spf/core/templates/user/profile.html deleted file mode 100644 index 049cb72..0000000 --- a/spf/core/templates/user/profile.html +++ /dev/null @@ -1,34 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% load spf_extras %} - -{% block title %} -SciELO Publishing Framework - {% trans 'Profile' %} -{% endblock %} - -{% block content %} -

{% trans 'Profile' %}

- -
-
-
-
{% trans 'User profile' %}
-
-
    -
  • {% trans 'Username' %}: {{ request.user.username }}
  • -
  • {% trans 'First name' %}: {{ request.user.first_name }}
  • -
  • {% trans 'Last name' %}: {{ request.user.last_name }}
  • -
  • {% trans 'E-mail' %}: {{ request.user.email }}
  • -
  • {% trans 'Last login date' %}: {{ request.user.last_login }}
  • -
  • {% trans 'Groups' %}: - {% for g in groups %} - {{ g|to_short_group_name }} - {% endfor %} -
  • -
-
-
-
-
- -{% endblock %} diff --git a/spf/core/templates/user/profile_edit.html b/spf/core/templates/user/profile_edit.html deleted file mode 100644 index e21a4d1..0000000 --- a/spf/core/templates/user/profile_edit.html +++ /dev/null @@ -1,36 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} - -{% load static %} - -{% block title %} -SciELO Publishing Framework - {% trans 'Edit profile' %} -{% endblock %} - -{% block content %} -

{% trans 'Edit profile' %}

- -
-
- {% csrf_token %} -
- - -
-
- - -
-
- - -
-
- - -
- -
-
- -{% endblock %} diff --git a/spf/core/templates/user/register.html b/spf/core/templates/user/register.html deleted file mode 100644 index 8832bc3..0000000 --- a/spf/core/templates/user/register.html +++ /dev/null @@ -1,45 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} - -{% load static %} - -{% block title %} -SciELO Publishing Framework - {% trans 'Sign up' %} -{% endblock %} - -{% block content %} -
- -
-

SciELO Publishing Framework

-
- {% csrf_token %} -
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
- -

{% trans 'Already have an account' %}?

{% trans 'Login' %}.
-{% endblock %} diff --git a/spf/core/templatetags/__init__.py b/spf/core/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/spf/core/templatetags/spf_extras.py b/spf/core/templatetags/spf_extras.py deleted file mode 100644 index ea00064..0000000 --- a/spf/core/templatetags/spf_extras.py +++ /dev/null @@ -1,62 +0,0 @@ -from django import template -from django.contrib.auth.models import Group -from django.utils.translation import gettext as _ -from dateutil import parser - - -register = template.Library() - - -@register.filter(name='has_group') -def has_group(user, group): - group = Group.objects.get(name=group) - return group in user.groups.all() - - -@register.filter(name='to_datetime') -def to_datetime(text): - if isinstance(text, str): - try: - return parser.parse(text) - except: - pass - return text - - -@register.filter(name='to_short_group_name') -def to_short_group_name(group): - if group == 'quality_analyst': - return _('Q. Analyst') - if group == 'operator_ingress': - return _('Op. Ingress') - if group == 'operator_migration': - return _('Op. Migration') - if group == 'manager': - return _('Manager') - return group.title() - - -@register.filter(name='to_css_event_status_style') -def to_css_event_status_style(event_status): - if event_status == 'I': - return 'bg-warning' - elif event_status == 'C': - return 'bg-success' - elif event_status == 'F': - return 'bg-danger' - else: - return 'bg-secondary' - - -@register.filter(name='to_css_ingress_package_status_style') -def to_css_ingress_package_status_style(ingress_package_status): - if ingress_package_status == 'R': - return 'bg-primary' - elif ingress_package_status == 'Q': - return 'bg-secondary' - elif ingress_package_status == 'D': - return 'bg-warning' - elif ingress_package_status == 'V': - return 'bg-success' - elif ingress_package_status == 'F': - return 'bg-danger' diff --git a/spf/core/tests.py b/spf/core/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/spf/core/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/spf/core/urls.py b/spf/core/urls.py deleted file mode 100644 index a44d35c..0000000 --- a/spf/core/urls.py +++ /dev/null @@ -1,37 +0,0 @@ -from django.urls import path -from . import views - - -general = [ - path('', views.index_page, name='index'), - path('faq/', views.faq_page, name='faq'), -] - -user = [ - path('register/', views.user_register_page, name='register'), - path('login/', views.user_login_page, name='login'), - path('logout/', views.user_logout, name='logout'), - path('user/add/', views.user_add_page, name='user_add'), - path('user/change_password/', views.user_change_password_page, name='user_change_password'), - path('user/groups/edit', views.user_groups_edit_page, name='user_groups_edit'), - path('user/profile/', views.user_profile_page, name='user_profile'), - path('user/profile/edit/', views.user_profile_edit_page, name='user_profile_edit'), -] - -ingress = [ - path('ingress/package_upload/', views.ingress_package_upload_page, name='ingress_package_upload'), - path('ingress/package_download/', views.ingress_package_download_page, name='ingress_package_download'), - path('ingress/package_list/', views.ingress_package_list_page, name='ingress_package_list'), - path('ingress/articles_files/', views.ingress_articles_files_page, name='ingress_article_files_list'), -] - -journal = [ - path('journal/list/', views.journal_list_page, name='journal_list'), -] - -tracking = [ - path('event/list/', views.event_list_page, name='event_list'), - path('task/update_status/', views.task_update_status, name='task_update_status'), -] - -urlpatterns = general + user + ingress + journal + tracking \ No newline at end of file diff --git a/spf/core/views.py b/spf/core/views.py deleted file mode 100644 index 83c84af..0000000 --- a/spf/core/views.py +++ /dev/null @@ -1,352 +0,0 @@ -from celery.result import AsyncResult -from django.contrib import messages -from django.contrib.auth import authenticate, login, logout, update_session_auth_hash -from django.contrib.auth.decorators import login_required -from django.contrib.auth.forms import PasswordChangeForm -from django.core.files.storage import FileSystemStorage -from django.core.paginator import Paginator -from django.urls import reverse -from django.http.response import HttpResponseRedirect, JsonResponse -from django.utils.translation import gettext as _ -from django.shortcuts import render, redirect -from core.forms import CreateUserForm, UpdateUserForm -from core.decorators import unauthenticated_user, allowed_users -from core.models import Event -from core.tasks import task_get_package_uri_by_pid -from spf import settings -from os import path - -import core.controller as controller -import dsm.ingress as dsm_ingress - - -################### -### general views # -################### -def index_page(request): - return render(request, 'index.html') - - -def faq_page(request): - return render(request, 'faq.html') - - -################ -### user views # -################ -@unauthenticated_user -def user_register_page(request): - if request.method == 'POST': - form = CreateUserForm(request.POST) - if form.is_valid(): - form.save() - username = form.cleaned_data.get('username') - messages.success(request, - _('User %s was created') % username, - extra_tags='alert-success') - return redirect('login') - else: - for val in form.errors.values(): - messages.error(request, _(val[0]), extra_tags='alert-danger') - context = { - 'username': request.POST.get('username', ''), - 'email': request.POST.get('email', ''), - 'first_name': request.POST.get('first_name', ''), - 'last_name': request.POST.get('last_name', '') - } - return render(request, 'user/register.html', context=context) - - -@unauthenticated_user -def user_login_page(request): - context = {'username': ''} - - if request.method == 'POST': - username = request.POST.get('username') - password = request.POST.get('password') - - user = authenticate(request, username=username, password=password) - - if user is not None: - login(request, user) - return redirect('index') - else: - messages.error(request, - _('Incorrect username or password'), - extra_tags='alert-danger') - context['username'] = username - - return render(request, 'user/login.html', context=context) - - -@login_required(login_url='login') -def user_logout(request): - logout(request) - return redirect('login') - - -@login_required(login_url='login') -@allowed_users(allowed_groups=['manager']) -def user_add_page(request): - context = {'user_groups': []} - - if request.method == 'POST': - form = CreateUserForm(request.POST) - - groups_names = request.POST.getlist('user_groups') - context.update({'user_groups': groups_names}) - - if form.is_valid(): - form.save() - username = form.cleaned_data.get('username') - user = controller.get_user_from_username(username) - user_groups = controller.get_groups_from_groups_names(groups_names) - controller.update_user_groups(user, user_groups) - - messages.success(request, - _('User %s was created') % username, - extra_tags='alert-success') - - else: - for val in form.errors.values(): - messages.error(request, _(val[0]), extra_tags='alert-danger') - - context.update({ - 'username': request.POST.get('username', ''), - 'email': request.POST.get('email', ''), - 'first_name': request.POST.get('first_name', ''), - 'last_name': request.POST.get('last_name', '') - }) - - context.update({'available_groups': controller.get_groups()}) - - return render(request, 'user/add.html', context=context) - - -@login_required(login_url='login') -def user_change_password_page(request): - context = {} - if request.method == 'POST': - form = PasswordChangeForm(request.user, request.POST) - if form.is_valid(): - user = form.save() - update_session_auth_hash(request, user) - messages.success( - request, - _('Your password was updated'), - extra_tags='alert-success' - ) - else: - for val in form.errors.values(): - messages.error(request, _(val[0]), extra_tags='alert-danger') - context.update({ - 'old_password': request.POST.get('old_password', ''), - 'new_password1': request.POST.get('new_password1', ''), - 'new_password2': request.POST.get('new_password2', ''), - 'form': form - }) - else: - form = PasswordChangeForm(request.user) - - return render(request, 'user/change_password.html', context=context) - - -@login_required(login_url='login') -@allowed_users(allowed_groups=['manager']) -def user_groups_edit_page(request): - user_list = controller.get_users() - available_groups = controller.get_groups() - - paginator = Paginator(user_list, 25) - page_number = request.GET.get('page') - user_obj = paginator.get_page(page_number) - - if request.method == 'POST': - ev = controller.add_event(request.user, Event.Name.CHANGE_USER_GROUPS) - - for u in user_obj: - groups_names = request.POST.getlist('%s|user_groups' % u.username) - user_groups = controller.get_groups_from_groups_names(groups_names) - controller.update_user_groups(u, user_groups) - - messages.success(request, _("Users' groups were updated"), extra_tags='alert-success') - controller.update_event(ev, {'status': Event.Status.COMPLETED}) - - return render(request, 'user/groups_edit.html', context={'user_obj': user_obj, 'available_groups': available_groups}) - - -@login_required(login_url='login') -def user_profile_page(request): - groups_names = controller.get_groups_names_from_user(request.user) - return render(request, 'user/profile.html', context={'groups': groups_names}) - - -@login_required(login_url='login') -def user_profile_edit_page(request): - if request.method == 'POST': - form = UpdateUserForm(request.POST, instance=request.user) - if form.is_valid(): - form.save() - username = form.cleaned_data.get('username') - messages.success(request, - _('User %s was updated') % username, - extra_tags='alert-success') - return redirect('user_profile_edit') - return render(request, 'user/profile_edit.html', context={}) - - -################# -# ingress views # -################# -@login_required(login_url='login') -@allowed_users(allowed_groups=['manager', 'operator_ingress']) -def ingress_package_upload_page(request): - if request.method == 'POST': - file_input = request.FILES.get('package_file') - # registra evento de envio de pacote novo - ev = controller.add_event(request.user, Event.Name.UPLOAD_PACKAGE, {'file_name': file_input.name}) - - if file_input: - fs = FileSystemStorage(location=settings.MEDIA_INGRESS_TEMP) - - # envia arquivo para diretório temporário - pkg_name = fs.save(file_input.name, file_input) - - # envia arquivo ao MinIO - try: - file_path = path.join(fs.base_location, pkg_name) - ingress_results = dsm_ingress.upload_package(file_path) - - if len(ingress_results['errors']) > 0: - messages.error(request, - _('Errors ocurred: %s') % ingress_results['errors'], - extra_tags='alert-danger') - # registra o evento como completado com falha - ev = controller.update_event(ev, {'status': Event.Status.FAILED}) - else: - for d in ingress_results['docs']: - messages.success(request, - _('Package (%(name)s, %(id)s) was added') - % {'name': d['name'], 'id': d['id']}, - extra_tags='alert-success') - # registra o evento como completado com sucesso - ev = controller.update_event(ev, {'status': Event.Status.COMPLETED}) - - # registra o pacote enviado - controller.add_ingress_package(request.user, ev.datetime, pkg_name) - except ValueError: - messages.error(request, - pkg_name + _(' does not have a valid format. Please provide a zip file.'), - extra_tags='alert-danger') - # registra o evento como completado com falha - ev = controller.update_event(ev, {'status': Event.Status.FAILED}) - - # remove arquivo de diretório temporário - fs.delete(pkg_name) - - return render(request, 'ingress/package_upload.html') - - -@login_required(login_url='login') -@allowed_users(allowed_groups=['manager', 'operator_ingress']) -def ingress_package_download_page(request): - pid = request.GET.get('pid', '') - job_id = request.GET.get('job', '') - - # Há task sendo executada: renderiza template para mostrar resultados (ou aguardar por eles) - if job_id: - job = AsyncResult(job_id) - - context = { - 'pid': pid, - 'check_status': 1, - 'data': '', - 'state': 'STARTING', - 'task_id': job_id - } - return render(request, 'ingress/package_download.html', context) - - # Inicializa task para o PID informado e redireciona para a própria página aguardando resultado - elif pid: - job = task_get_package_uri_by_pid.delay(pid) - return HttpResponseRedirect(reverse('ingress_package_download') + '?job=' + job.id + '&pid=' + pid) - - # Abre template pela primeira vez para digitar PID - return render(request, 'ingress/package_download.html') - - -@login_required(login_url='login') -@allowed_users(allowed_groups=['manager', 'operator_ingress']) -def ingress_package_list_page(request): - request_scope = request.GET.get('scope', '') - deposited_package_list = controller.get_ingress_packages_from_user_and_scope(request.user, request_scope) - - paginator = Paginator(deposited_package_list, 25) - page_number = request.GET.get('page') - deposited_package_obj = paginator.get_page(page_number) - - return render(request, 'ingress/package_list.html', context={'deposited_package_obj': deposited_package_obj, 'scope': request_scope}) - - -@login_required(login_url='login') -@allowed_users(allowed_groups=['manager', 'operator_ingress']) -def ingress_articles_files_page(request): - article_files_list = dsm_ingress._docs_manager.get_articles_files() - - paginator = Paginator(article_files_list, 25) - page_number = request.GET.get('page') - article_files_obj = paginator.get_page(page_number) - - return render(request, 'ingress/article_files_list.html', context={'article_files_obj': article_files_obj}) - - -################# -# journal views # -################# -@login_required(login_url='login') -@allowed_users(allowed_groups=['manager', 'operator_ingress']) -def journal_list_page(request): - journal_list = dsm_ingress._journals_manager.get_journals() - - paginator = Paginator(journal_list, 25) - page_number = request.GET.get('page') - journal_obj = paginator.get_page(page_number) - - return render(request, 'journal/journal_list.html', context={'journal_obj': journal_obj}) - - -################## -# tracking views # -################## -@login_required(login_url='login') -def event_list_page(request): - request_scope = request.GET.get('scope', '') - event_list = controller.get_events_from_user_and_scope(request.user, request_scope) - - paginator = Paginator(event_list, 25) - page_number = request.GET.get('page') - event_obj = paginator.get_page(page_number) - - return render(request, 'tracking/event_list.html', context={'event_obj': event_obj, 'scope': request_scope}) - - -@login_required(login_url='login') -@allowed_users(allowed_groups=['manager', 'operator_ingress', 'operator_migration', 'quality_analyst']) -def task_update_status(request): - """Obtém status (STARTING, FAILURY, PROGRESS, SUCCESS ou UNDEFINED) de task executada.""" - try: - task_id = request.GET['task_id'] - task = AsyncResult(task_id) - result = task.result - status = task.status - except: - result = 'UNDEFINED' - status = 'UNDEFINED' - - json_data = { - 'status': status, - 'state': 'PROGRESS', - 'data': result, - } - - return JsonResponse(json_data) diff --git a/spf/manage.py b/spf/manage.py deleted file mode 100755 index bde4148..0000000 --- a/spf/manage.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python -"""Django's command-line utility for administrative tasks.""" -import os -import sys - - -def main(): - """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'spf.settings') - try: - from django.core.management import execute_from_command_line - except ImportError as exc: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) from exc - execute_from_command_line(sys.argv) - - -if __name__ == '__main__': - main() diff --git a/spf/spf/__init__.py b/spf/spf/__init__.py deleted file mode 100644 index fb989c4..0000000 --- a/spf/spf/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .celery import app as celery_app - -__all__ = ('celery_app',) diff --git a/spf/spf/asgi.py b/spf/spf/asgi.py deleted file mode 100644 index 485f1da..0000000 --- a/spf/spf/asgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -ASGI config for spf project. - -It exposes the ASGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ -""" - -import os - -from django.core.asgi import get_asgi_application - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'spf.settings') - -application = get_asgi_application() diff --git a/spf/spf/celery.py b/spf/spf/celery.py deleted file mode 100644 index 81744e8..0000000 --- a/spf/spf/celery.py +++ /dev/null @@ -1,10 +0,0 @@ -import os - -from celery import Celery - - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'spf.settings') - -app = Celery('spf') -app.config_from_object('django.conf.settings', namespace='CELERY') -app.autodiscover_tasks() diff --git a/spf/spf/settings.py b/spf/spf/settings.py deleted file mode 100644 index 067d9dc..0000000 --- a/spf/spf/settings.py +++ /dev/null @@ -1,117 +0,0 @@ -import os -from pathlib import Path -from django.utils.translation import ugettext_lazy as _ - - -BASE_DIR = Path(__file__).resolve().parent.parent - -SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY') - -DEBUG = int(os.environ.get('DJANGO_DEBUG', '0')) - -ALLOWED_HOSTS = os.environ.get('DJANGO_ALLOWED_HOSTS').split(';') - -INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'core.apps.CoreConfig', - 'django_celery_results', -] - -MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'django.middleware.locale.LocaleMiddleware', -] - -ROOT_URLCONF = 'spf.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'templates')], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - }, - }, -] - -WSGI_APPLICATION = 'spf.wsgi.application' - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': os.environ.get('POSTGRES_DB', 'spf'), - 'USER': os.environ.get('POSTGRES_USER', 'user'), - 'PASSWORD': os.environ.get('POSTGRES_PASSWORD', 'password'), - 'HOST': os.environ.get('POSTGRES_HOST', 'scielo-postgres-1'), - 'PORT': int(os.environ.get('POSTGRES_PORT', '5432')), - }, -} - -AUTH_PASSWORD_VALIDATORS = [ - { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', - }, -] - -LANGUAGE_CODE = 'pt-br' - -LANGUAGES = ( - ('en', _('English')), - ('pt', _('Portuguese')), - ('es', _('Spanish')), - ('de', _('German')), -) - -TIME_ZONE = 'UTC' - -USE_I18N = True - -USE_L10N = True - -USE_TZ = True - -STATIC_URL = '/static/' - -STATIC_ROOT = os.path.join(BASE_DIR, 'static') - -DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' - -LOGIN_REDIRECT_URL = '/' - -EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' - -MEDIA_URL = '/media/' - -MEDIA_ROOT = os.path.join(BASE_DIR, 'media') - -MEDIA_INGRESS_TEMP = os.path.join(BASE_DIR, 'media', 'ingress', 'temp') - -CELERY_BROKER_URL = os.environ.get('CELERY_BROKER_URL', 'pyamqp://broker:5672'), - -CELERY_RESULT_BACKEND = 'django-db' diff --git a/spf/spf/urls.py b/spf/spf/urls.py deleted file mode 100644 index 75fa897..0000000 --- a/spf/spf/urls.py +++ /dev/null @@ -1,23 +0,0 @@ -"""spf URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/3.2/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" -from django.contrib import admin -from django.urls import path, include - - -urlpatterns = [ - path('admin/', admin.site.urls), - path('', include('core.urls')), -] diff --git a/spf/spf/wsgi.py b/spf/spf/wsgi.py deleted file mode 100644 index 48f2c25..0000000 --- a/spf/spf/wsgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -WSGI config for spf project. - -It exposes the WSGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'spf.settings') - -application = get_wsgi_application() From ce140f96bc9adab872f5712eb0f943c9b346c061 Mon Sep 17 00:00:00 2001 From: Rafael J P D Date: Mon, 1 Nov 2021 21:52:57 -0300 Subject: [PATCH 02/10] adiciona dockerignore --- .dockerignore | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e12d0af --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/__pycache__ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/bin +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +README.md From 4bff6849d6b48a78f2317344389ce1764321d03d Mon Sep 17 00:00:00 2001 From: Rafael J P D Date: Mon, 1 Nov 2021 21:54:04 -0300 Subject: [PATCH 03/10] atualiza gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 7aea42e..f9ebf31 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ # Others data/ +env.dev +env.prod +*.vscode # Byte-compiled / optimized / DLL files __pycache__/ From ac0c823a5425e7af89af5ac574eb0864a0a41b57 Mon Sep 17 00:00:00 2001 From: Rafael J P D Date: Mon, 1 Nov 2021 21:54:43 -0300 Subject: [PATCH 04/10] =?UTF-8?q?adiciona=20vers=C3=A3o=20atualizada=20de?= =?UTF-8?q?=20docker-compose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 94 ++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 44 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index adac723..3528db7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,44 +1,50 @@ -version: "3.2" - -services: - broker: - image: rabbitmq:3-alpine - container_name: 'spf_broker_1' - ports: - - 5672:5672 - networks: - - net - worker: - build: - context: . - container_name: 'spf_worker_1' - user: nobody - command: sh docker-start-worker.sh - env_file: - - ./prod.env - depends_on: - - broker - external_links: - - scielo-postgres-1 - networks: - - net - web: - build: . - container_name: 'spf_web_1' - user: nobody - command: python spf/manage.py runserver 0.0.0.0:8000 - ports: - - 8000:8000 - depends_on: - - broker - - worker - env_file: - - ./prod.env - external_links: - - scielo-postgres-1 - - opac_opac_mongo_1 - networks: - - net -networks: - net: - driver: bridge +version: '3.7' + +services: + web: + build: + context: ./app + dockerfile: Dockerfile + command: gunicorn spf.wsgi:application --bind 0.0.0.0:8000 + volumes: + - static_volume:/home/app/web/staticfiles + - media_volume:/home/app/web/mediafiles + expose: + - 8000 + env_file: + - ./.env.prod + depends_on: + - broker + - worker + external_links: + - scl_postgres_1 + - scl_mongo_1 + worker: + build: + context: ./app + dockerfile: Dockerfile + command: celery -A spf worker -l INFO + env_file: + - ./.env.prod + depends_on: + - broker + external_links: + - scl_postgres_1 + broker: + image: rabbitmq:3-alpine + ports: + - 5672:5672 + nginx: + build: + context: ./nginx + volumes: + - static_volume:/home/app/web/staticfiles + - media_volume:/home/app/web/mediafiles + ports: + - 1337:80 + depends_on: + - web + +volumes: + static_volume: + media_volume: From bf56873513651bd8c43b02f59434a3842c475946 Mon Sep 17 00:00:00 2001 From: Rafael J P D Date: Mon, 1 Nov 2021 21:54:53 -0300 Subject: [PATCH 05/10] =?UTF-8?q?adiciona=20vers=C3=A3o=20atualizada=20de?= =?UTF-8?q?=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Dockerfile | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 app/Dockerfile diff --git a/app/Dockerfile b/app/Dockerfile new file mode 100644 index 0000000..7b7f249 --- /dev/null +++ b/app/Dockerfile @@ -0,0 +1,47 @@ +FROM python:3.9.6-alpine + +WORKDIR /usr/src/app + +ENV PYTHONDONTWRITEBYTECODE 1 + +ENV PYTHONUNBUFFERED 1 + +RUN apk update \ + && apk add postgresql-dev \ + gcc \ + git \ + build-base \ + py3-lxml \ + python3-dev \ + musl-dev \ + libxml2-dev \ + libxslt-dev \ + libffi-dev + +RUN pip install --upgrade pip + +COPY ./requirements.txt . + +RUN pip install -r requirements.txt + +RUN mkdir -p /home/app + +RUN addgroup -S app && adduser -S app -G app + +ENV HOME=/home/app + +ENV APP_HOME=/home/app/web + +RUN mkdir ${APP_HOME} + +RUN mkdir ${APP_HOME}/staticfiles + +RUN mkdir ${APP_HOME}/mediafiles + +WORKDIR ${APP_HOME} + +COPY . ${APP_HOME} + +RUN chown -R app:app ${APP_HOME} + +USER app From f0d25229a80a4c602aed5dc19eb0b446b5f2c9e7 Mon Sep 17 00:00:00 2001 From: Rafael J P D Date: Mon, 1 Nov 2021 21:55:03 -0300 Subject: [PATCH 06/10] adiciona conf de nginx --- nginx/Dockerfile | 4 ++++ nginx/nginx.conf | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 nginx/Dockerfile create mode 100644 nginx/nginx.conf diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 0000000..29ffd3c --- /dev/null +++ b/nginx/Dockerfile @@ -0,0 +1,4 @@ +FROM nginx:1.21-alpine + +RUN rm /etc/nginx/conf.d/default.conf +COPY nginx.conf /etc/nginx/conf.d \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..0faf5da --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,24 @@ +upstream upload_scielo { + server web:8000; +} + +server { + listen 80; + + location / { + proxy_pass http://upload_scielo; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + proxy_redirect off; + client_max_body_size 100M; + } + + location /static/ { + alias /home/app/web/staticfiles/; + } + + location /media/ { + alias /home/app/web/mediafiles/; + } + +} \ No newline at end of file From 885ffa302fa66ebaedcbf7d6d89077916edada80 Mon Sep 17 00:00:00 2001 From: Rafael J P D Date: Mon, 1 Nov 2021 21:56:08 -0300 Subject: [PATCH 07/10] adiciona base do app spf --- app/manage.py | 22 ++++++++ app/requirements.txt | 15 ++++++ app/setup.py | 58 +++++++++++++++++++++ app/spf/__init__.py | 3 ++ app/spf/asgi.py | 16 ++++++ app/spf/celery.py | 10 ++++ app/spf/settings.py | 117 +++++++++++++++++++++++++++++++++++++++++++ app/spf/urls.py | 23 +++++++++ app/spf/wsgi.py | 16 ++++++ 9 files changed, 280 insertions(+) create mode 100644 app/manage.py create mode 100644 app/requirements.txt create mode 100644 app/setup.py create mode 100644 app/spf/__init__.py create mode 100644 app/spf/asgi.py create mode 100644 app/spf/celery.py create mode 100644 app/spf/settings.py create mode 100644 app/spf/urls.py create mode 100644 app/spf/wsgi.py diff --git a/app/manage.py b/app/manage.py new file mode 100644 index 0000000..bde4148 --- /dev/null +++ b/app/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'spf.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/app/requirements.txt b/app/requirements.txt new file mode 100644 index 0000000..52a306c --- /dev/null +++ b/app/requirements.txt @@ -0,0 +1,15 @@ +#asgiref==3.4.1 +celery==5.1.2 +#confusable-homoglyphs==3.2.0 +Django==3.2.6 +django-celery-results==2.2.0 +psycopg2-binary==2.9.1 +#pytz==2021.1 +python-dateutil==2.8.2 +#sqlparse==0.4.1 +lxml==4.6.3 +minio==7.1.0 +gunicorn==20.1.0 +-e git+https://github.com/scieloorg/opac_schema.git#egg=opac_schema +-e git+https://github.com/scieloorg/dsm.git#egg=dsm +-e git+https://github.com/scieloorg/scielo_v3_manager.git#egg=scielo_v3_manager diff --git a/app/setup.py b/app/setup.py new file mode 100644 index 0000000..3a0f44b --- /dev/null +++ b/app/setup.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +import os, setuptools + +here = os.path.abspath(os.path.dirname(__file__)) +with open(os.path.join(here, "README.md")) as f: + README = f.read() + +requires = [ + 'asgiref', + 'celery', + 'confusable-homoglyphs', + 'Django', + 'django-celery-results', + 'gunicorn', + 'pytz', + 'python-dateutil', + 'sqlparse', + 'minio', + 'lxml', + 'opac_schema', + 'dsm', + 'scielo_v3_manager', +] + +tests_require = [ +] + +setuptools.setup( + name="SciELO Publishing Framework", + version="0.1", + author="SciELO", + author_email="scielo-dev@googlegroups.com", + description="", + long_description=README, + long_description_content_type="text/markdown", + license="2-clause BSD", + packages=setuptools.find_packages( + exclude=["*.tests", "*.tests.*", "tests.*", "tests"] + ), + include_package_data=True, + extras_require={"testing": tests_require}, + install_requires=requires, + dependency_links=[ + ], + python_requires=">=3.6", + test_suite="tests", + classifiers=[ + "Development Status :: 2 - Pre-Alpha", + "Environment :: Other Environment", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Internet :: WWW/HTTP", + "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", + "Operating System :: OS Independent", + ], +) diff --git a/app/spf/__init__.py b/app/spf/__init__.py new file mode 100644 index 0000000..fb989c4 --- /dev/null +++ b/app/spf/__init__.py @@ -0,0 +1,3 @@ +from .celery import app as celery_app + +__all__ = ('celery_app',) diff --git a/app/spf/asgi.py b/app/spf/asgi.py new file mode 100644 index 0000000..485f1da --- /dev/null +++ b/app/spf/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for spf project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'spf.settings') + +application = get_asgi_application() diff --git a/app/spf/celery.py b/app/spf/celery.py new file mode 100644 index 0000000..81744e8 --- /dev/null +++ b/app/spf/celery.py @@ -0,0 +1,10 @@ +import os + +from celery import Celery + + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'spf.settings') + +app = Celery('spf') +app.config_from_object('django.conf.settings', namespace='CELERY') +app.autodiscover_tasks() diff --git a/app/spf/settings.py b/app/spf/settings.py new file mode 100644 index 0000000..30d02c4 --- /dev/null +++ b/app/spf/settings.py @@ -0,0 +1,117 @@ +import os +from pathlib import Path +from django.utils.translation import ugettext_lazy as _ + + +BASE_DIR = Path(__file__).resolve().parent.parent + +SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY') + +DEBUG = int(os.environ.get('DJANGO_DEBUG', 0)) + +ALLOWED_HOSTS = os.environ.get('DJANGO_ALLOWED_HOSTS').split(' ') + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'core.apps.CoreConfig', + 'django_celery_results', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.locale.LocaleMiddleware', +] + +ROOT_URLCONF = 'spf.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR, 'templates')], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'spf.wsgi.application' + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': os.environ.get('POSTGRES_DB', 'spf'), + 'USER': os.environ.get('POSTGRES_USER', 'postgres'), + 'PASSWORD': os.environ.get('POSTGRES_PASSWORD', 'pass'), + 'HOST': os.environ.get('POSTGRES_HOST', 'db'), + 'PORT': int(os.environ.get('POSTGRES_PORT', '5432')), + }, +} + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + +LANGUAGE_CODE = 'pt-br' + +LANGUAGES = ( + ('en', _('English')), + ('pt', _('Portuguese')), + ('es', _('Spanish')), + ('de', _('German')), +) + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + +STATIC_URL = '/static/' + +STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +LOGIN_REDIRECT_URL = '/' + +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + +MEDIA_URL = '/media/' + +MEDIA_ROOT = os.path.join(BASE_DIR, 'mediafiles') + +MEDIA_INGRESS_TEMP = os.path.join(MEDIA_ROOT, 'ingress', 'tmp') + +CELERY_BROKER_URL = os.environ.get('CELERY_BROKER_URL', 'pyamqp://broker:5672'), + +CELERY_RESULT_BACKEND = 'django-db' diff --git a/app/spf/urls.py b/app/spf/urls.py new file mode 100644 index 0000000..75fa897 --- /dev/null +++ b/app/spf/urls.py @@ -0,0 +1,23 @@ +"""spf URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path, include + + +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include('core.urls')), +] diff --git a/app/spf/wsgi.py b/app/spf/wsgi.py new file mode 100644 index 0000000..48f2c25 --- /dev/null +++ b/app/spf/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for spf project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'spf.settings') + +application = get_wsgi_application() From 2002c2895af0e32673cc5977c1f95e1983f287d2 Mon Sep 17 00:00:00 2001 From: Rafael J P D Date: Mon, 1 Nov 2021 21:56:19 -0300 Subject: [PATCH 08/10] =?UTF-8?q?adiciona=20est=C3=A1ticos=20do=20app?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/css/style.css | 10 ++++++ app/static/img/logo-scielo.svg | 1 + app/static/js/main.js | 65 ++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 app/static/css/style.css create mode 100644 app/static/img/logo-scielo.svg create mode 100644 app/static/js/main.js diff --git a/app/static/css/style.css b/app/static/css/style.css new file mode 100644 index 0000000..5bbfb99 --- /dev/null +++ b/app/static/css/style.css @@ -0,0 +1,10 @@ +.form-user { + width: 100%; + max-width: 400px; + padding: 0; + margin: 0 auto; +} + +.is-no-rounded { + border-radius: 0; +} diff --git a/app/static/img/logo-scielo.svg b/app/static/img/logo-scielo.svg new file mode 100644 index 0000000..672fc14 --- /dev/null +++ b/app/static/img/logo-scielo.svg @@ -0,0 +1 @@ +logo-scielo-portal-no-label-2 \ No newline at end of file diff --git a/app/static/js/main.js b/app/static/js/main.js new file mode 100644 index 0000000..3aa057f --- /dev/null +++ b/app/static/js/main.js @@ -0,0 +1,65 @@ +function createMessage(msg){ + divAlert = document.createElement('div'); + divAlert.classList.add('alert', 'alert-danger', 'alert-dismissible', 'fade', 'show', 'is-no-rounded', 'm-0', 'p-2'); + divAlert.setAttribute('role', 'alert'); + + divContainer = document.createElement('div'); + divContainer.classList.add('container', 'text-center'); + divContainer.innerHTML = msg; + + btnClose = document.createElement('button'); + btnClose.type = 'button'; + btnClose.classList.add('btn-close', 'btn-sm', 'm-1', 'p-2'); + btnClose.setAttribute('data-bs-dismiss', 'alert'); + btnClose.setAttribute('aria-label', 'Close'); + + divContainer.appendChild(btnClose); + divAlert.appendChild(divContainer); + + return divAlert; +} + +function ingressPackageDownloadToggleSpinner(){ + var btnSearchPackage = document.getElementById('btnSearchPackage'); + var divSpinner = document.getElementById('searchPackageLoading'); + if (divSpinner.style.display == "none") { + divSpinner.style.display = 'block'; + btnSearchPackage.setAttribute('disabled', 'disabled'); + } else { + divSpinner.style.display = 'none'; + btnSearchPackage.removeAttribute('disabled'); + } +} + +function ingressPackageDownloadCreateTable(data){ + tableBody = document.getElementById('resultSearchPackagesTableBody') + + for (k in data['doc_pkg']){ + els = data['doc_pkg'][k]; + row = tableBody.insertRow(-1); + + aResult = document.createElement('a') + aResult.text = els['name']; + aResult.href = els['uri']; + aResult.classList.add('link'); + + tdUri = row.insertCell(-1); + tdUri.appendChild(aResult); + + tdCreated = row.insertCell(-1); + tdCreated.innerHTML = els['created']; + + tdUpdated = row.insertCell(-1); + tdUpdated.innerHTML = els['updated']; + } + + if (data['doc_pkg'].length > 0) { + document.getElementById('resultSearchPackages').style.display = 'block'; + } else { + var divBaseMessages = document.getElementById('baseMessages'); + for (k in data['errors']){ + element_message = createMessage(data['errors'][k]); + divBaseMessages.append(element_message); + } + } +} From e43542147c172720fa9f07002a24e0c2fe8f56cf Mon Sep 17 00:00:00 2001 From: Rafael J P D Date: Mon, 1 Nov 2021 21:56:43 -0300 Subject: [PATCH 09/10] adiciona base do app core --- app/core/__init__.py | 0 app/core/admin.py | 7 + app/core/apps.py | 6 + app/core/controller.py | 87 +++ app/core/decorators.py | 34 ++ app/core/fixtures/group.json | 1 + app/core/fixtures/user.json | 1 + app/core/forms.py | 53 ++ app/core/locale/es/LC_MESSAGES/django.po | 547 ++++++++++++++++++ app/core/locale/pt/LC_MESSAGES/django.po | 546 +++++++++++++++++ .../commands/make_messages_no_fuzzy.py | 5 + app/core/migrations/__init__.py | 0 app/core/models.py | 67 +++ app/core/static/css/style.css | 10 + app/core/static/img/logo-scielo.svg | 1 + app/core/static/js/main.js | 65 +++ app/core/tasks.py | 19 + app/core/templates/base.html | 80 +++ app/core/templates/faq.html | 12 + app/core/templates/index.html | 109 ++++ .../templates/ingress/article_files_list.html | 79 +++ .../templates/ingress/package_download.html | 90 +++ app/core/templates/ingress/package_list.html | 70 +++ .../templates/ingress/package_upload.html | 28 + app/core/templates/journal/journal_list.html | 73 +++ app/core/templates/tracking/event_list.html | 80 +++ app/core/templates/user/add.html | 49 ++ app/core/templates/user/change_password.html | 31 + app/core/templates/user/groups_edit.html | 88 +++ app/core/templates/user/login.html | 28 + app/core/templates/user/profile.html | 34 ++ app/core/templates/user/profile_edit.html | 36 ++ app/core/templates/user/register.html | 45 ++ app/core/templatetags/__init__.py | 0 app/core/templatetags/spf_extras.py | 62 ++ app/core/tests.py | 3 + app/core/urls.py | 37 ++ app/core/views.py | 352 +++++++++++ 38 files changed, 2835 insertions(+) create mode 100644 app/core/__init__.py create mode 100644 app/core/admin.py create mode 100644 app/core/apps.py create mode 100644 app/core/controller.py create mode 100644 app/core/decorators.py create mode 100644 app/core/fixtures/group.json create mode 100644 app/core/fixtures/user.json create mode 100644 app/core/forms.py create mode 100644 app/core/locale/es/LC_MESSAGES/django.po create mode 100644 app/core/locale/pt/LC_MESSAGES/django.po create mode 100644 app/core/management/commands/make_messages_no_fuzzy.py create mode 100644 app/core/migrations/__init__.py create mode 100644 app/core/models.py create mode 100644 app/core/static/css/style.css create mode 100644 app/core/static/img/logo-scielo.svg create mode 100644 app/core/static/js/main.js create mode 100644 app/core/tasks.py create mode 100644 app/core/templates/base.html create mode 100644 app/core/templates/faq.html create mode 100644 app/core/templates/index.html create mode 100644 app/core/templates/ingress/article_files_list.html create mode 100644 app/core/templates/ingress/package_download.html create mode 100644 app/core/templates/ingress/package_list.html create mode 100644 app/core/templates/ingress/package_upload.html create mode 100644 app/core/templates/journal/journal_list.html create mode 100644 app/core/templates/tracking/event_list.html create mode 100644 app/core/templates/user/add.html create mode 100644 app/core/templates/user/change_password.html create mode 100644 app/core/templates/user/groups_edit.html create mode 100644 app/core/templates/user/login.html create mode 100644 app/core/templates/user/profile.html create mode 100644 app/core/templates/user/profile_edit.html create mode 100644 app/core/templates/user/register.html create mode 100644 app/core/templatetags/__init__.py create mode 100644 app/core/templatetags/spf_extras.py create mode 100644 app/core/tests.py create mode 100644 app/core/urls.py create mode 100644 app/core/views.py diff --git a/app/core/__init__.py b/app/core/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/core/admin.py b/app/core/admin.py new file mode 100644 index 0000000..21245b7 --- /dev/null +++ b/app/core/admin.py @@ -0,0 +1,7 @@ +from django.contrib import admin +from .models import Event, IngressPackage, ValidationSchema, Validation + +admin.site.register(Event) +admin.site.register(IngressPackage) +admin.site.register(ValidationSchema) +admin.site.register(Validation) diff --git a/app/core/apps.py b/app/core/apps.py new file mode 100644 index 0000000..8115ae6 --- /dev/null +++ b/app/core/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class CoreConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'core' diff --git a/app/core/controller.py b/app/core/controller.py new file mode 100644 index 0000000..8687143 --- /dev/null +++ b/app/core/controller.py @@ -0,0 +1,87 @@ +from datetime import datetime +from django.contrib.auth.models import Group, User +from core.models import GROUP_MANAGER, SCOPE_ALL_USERS, IngressPackage, Event + + +def _is_privileged_user(user): + return GROUP_MANAGER in get_groups_names_from_user(user) or user.is_superuser or user.is_staff + + +def _get_objects_from_user_and_scope(user, scope, model_class): + if scope == SCOPE_ALL_USERS and _is_privileged_user(user): + return model_class.objects.all() + else: + return model_class.objects.filter(user=user) + + +def get_ingress_packages_from_user_and_scope(user, scope): + return _get_objects_from_user_and_scope(user, scope, IngressPackage) + + +def get_events_from_user_and_scope(user, scope): + return _get_objects_from_user_and_scope(user, scope, Event) + + +def get_user_from_username(username): + return User.objects.get(username=username) + + +def get_users(include_superuser=False): + return User.objects.filter(is_superuser=include_superuser) + + +def get_groups_names_from_user(user): + return [g.name for g in user.groups.all()] + + +def get_groups_from_user(user): + return Group.objects.filter(user=user) + + +def update_user_groups(user, user_groups): + for group in get_groups(): + if group not in user_groups: + user.groups.remove(group) + + for ug in user_groups: + user.groups.add(ug) + user.save() + + +def get_groups_from_groups_names(groups_names): + return Group.objects.filter(name__in=groups_names) + + +def get_groups(): + return Group.objects.all() + + +def add_event(user, event_name, annotation=None): + event = Event() + event.user = user + event.name = event_name + event.annotation = annotation + event.status = Event.Status.INITIATED + event.save() + + return event + + +def update_event(event, args): + for k, v in args.items(): + setattr(event, k, v) + event.datetime = datetime.utcnow() + event.save() + + return event + + +def add_ingress_package(user, event_datetime, package_name): + ip = IngressPackage() + ip.user = user + ip.datetime = event_datetime + ip.package_name = package_name + ip.status = IngressPackage.Status.RECEIVED + ip.save() + + return ip diff --git a/app/core/decorators.py b/app/core/decorators.py new file mode 100644 index 0000000..03d982b --- /dev/null +++ b/app/core/decorators.py @@ -0,0 +1,34 @@ +from django.contrib import messages +from django.shortcuts import redirect +from django.utils.translation import gettext as _ + + +def unauthenticated_user(view): + def wrapper(request, *args, **kwargs): + if request.user.is_authenticated: + return redirect('index') + else: + return view(request, *args, **kwargs) + + return wrapper + + +def allowed_users(allowed_groups=[]): + def decorator(view): + def wrapper(request, *args, **kwargs): + if request.user.is_superuser: + return view(request, *args, **kwargs) + elif request.user.groups.exists(): + for gn in [g.name for g in request.user.groups.all()]: + if gn in allowed_groups: + return view(request, *args, **kwargs) + messages.warning(request, + _('You do not have permission to access the requested page ') + request.path, + extra_tags='alert-warning') + return redirect('index') + messages.warning(request, + _('You do not have permission to access the requested page ') + request.path, + extra_tags='alert-warning') + return redirect('index') + return wrapper + return decorator diff --git a/app/core/fixtures/group.json b/app/core/fixtures/group.json new file mode 100644 index 0000000..25b4310 --- /dev/null +++ b/app/core/fixtures/group.json @@ -0,0 +1 @@ +[{"model": "auth.group", "pk": 1, "fields": {"name": "operator_ingress", "permissions": [4, 12, 8, 16, 20, 25, 26, 28, 29, 30, 32, 37, 38, 39, 40, 33, 34, 36, 24]}}, {"model": "auth.group", "pk": 2, "fields": {"name": "operator_migration", "permissions": [4, 12, 8, 16, 20, 41, 42, 43, 44, 25, 26, 28, 29, 30, 32, 33, 34, 36, 24]}}, {"model": "auth.group", "pk": 3, "fields": {"name": "manager", "permissions": [4, 9, 10, 11, 12, 5, 6, 8, 13, 14, 15, 16, 20, 41, 42, 43, 44, 25, 26, 27, 28, 29, 30, 31, 32, 37, 38, 39, 40, 33, 34, 35, 36, 24]}}, {"model": "auth.group", "pk": 4, "fields": {"name": "quality_analyst", "permissions": [4, 12, 5, 8, 16, 17, 18, 20, 41, 42, 44, 26, 28, 30, 32, 37, 38, 40, 33, 34, 36, 21, 22, 24]}}] \ No newline at end of file diff --git a/app/core/fixtures/user.json b/app/core/fixtures/user.json new file mode 100644 index 0000000..d19baff --- /dev/null +++ b/app/core/fixtures/user.json @@ -0,0 +1 @@ +[{"model": "auth.user", "pk": 1, "fields": {"password": "pbkdf2_sha256$260000$9lTnCt02OOX04bDA3VIgxR$0yRbSM7QkXtJcZWhqexUHICtV2uVSQD6RUbuEMqjG78=", "last_login": "2021-08-27T15:25:09.006Z", "is_superuser": true, "username": "superspf", "first_name": "", "last_name": "", "email": "", "is_staff": true, "is_active": true, "date_joined": "2021-08-27T15:24:57.596Z", "groups": [], "user_permissions": []}}, {"model": "auth.user", "pk": 2, "fields": {"password": "pbkdf2_sha256$260000$Zzjo7NSm4yG4xntIc129Bq$g54JaMwgFmEIM+SB9189RDNyrZmyEpXu0vHncusWMz4=", "last_login": "2021-09-14T22:34:04.101Z", "is_superuser": false, "username": "ingress1", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-08-27T15:26:36Z", "groups": [1], "user_permissions": []}}, {"model": "auth.user", "pk": 3, "fields": {"password": "pbkdf2_sha256$260000$P73ywmSRSpuf05lzXrB2IA$JkxLsy3bMBXz79U2NOMwhcz6NWfsRtETNhVpKH3MoT4=", "last_login": "2021-09-13T20:54:06.343Z", "is_superuser": false, "username": "ingress2", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-08-27T15:26:43Z", "groups": [1], "user_permissions": []}}, {"model": "auth.user", "pk": 4, "fields": {"password": "pbkdf2_sha256$260000$2Z1ZK71dXhYRWL3LAQFIRM$8i7SHKiU1N6ZPdfQlU5ybqJXoCTalAufoiYWWTv0ejM=", "last_login": "2021-09-14T14:04:45.688Z", "is_superuser": false, "username": "migration1", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-08-27T15:27:00Z", "groups": [2], "user_permissions": []}}, {"model": "auth.user", "pk": 5, "fields": {"password": "pbkdf2_sha256$260000$Ps6lNmwTNp32rHq7oCO9QF$GOebLa2Zx0Jp2LvL9ISomn+tzDCX3E0BU8vpPS/qSwo=", "last_login": "2021-09-14T13:40:29.277Z", "is_superuser": false, "username": "migration2", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-08-27T15:27:08Z", "groups": [2], "user_permissions": []}}, {"model": "auth.user", "pk": 6, "fields": {"password": "pbkdf2_sha256$260000$KWMZsotGHfClKR7v6t5kCn$uUJgBWIQieWUMdtPUXVvAaae06qLmCdKEYGT/1dWcYM=", "last_login": "2021-09-14T22:25:07.943Z", "is_superuser": false, "username": "manager1", "first_name": "", "last_name": "", "email": "", "is_staff": true, "is_active": true, "date_joined": "2021-08-27T15:27:16Z", "groups": [3], "user_permissions": []}}, {"model": "auth.user", "pk": 7, "fields": {"password": "pbkdf2_sha256$260000$Qa4tdhycurgmOrIMnGcOsc$7tlzyqCsv5CO19uQLhMXuBVq90K9/nRxQIKoM2uYcbQ=", "last_login": null, "is_superuser": false, "username": "manager2", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-08-27T15:27:31Z", "groups": [3], "user_permissions": []}}, {"model": "auth.user", "pk": 8, "fields": {"password": "pbkdf2_sha256$260000$Rk5A5ejNCT3eH5MuS7mdNQ$JGFCDZMJMRhAooMA3+hR8m834zQCFh0kgzZXWNI1GDQ=", "last_login": "2021-09-14T13:08:23.113Z", "is_superuser": false, "username": "migration3", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-09-14T13:08:14.509Z", "groups": [], "user_permissions": []}}, {"model": "auth.user", "pk": 9, "fields": {"password": "pbkdf2_sha256$260000$NT9OReetFbBHhwJTGNDMkB$6TemneVNPTW8WqnK+VrDLoEThMHqGlWl7v+DFJMmmMk=", "last_login": "2021-09-14T22:33:06.087Z", "is_superuser": false, "username": "quality1", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-09-14T22:32:10Z", "groups": [4], "user_permissions": []}}, {"model": "auth.user", "pk": 10, "fields": {"password": "pbkdf2_sha256$260000$fBtq2ygD72U2fXZQvcqLF7$5HVIRLyYPXOmf5t6bqkpzEBA7w1MHNYt14G9rJdxtSA=", "last_login": null, "is_superuser": false, "username": "quality2", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2021-09-14T22:32:27Z", "groups": [4], "user_permissions": []}}] \ No newline at end of file diff --git a/app/core/forms.py b/app/core/forms.py new file mode 100644 index 0000000..9b8bfef --- /dev/null +++ b/app/core/forms.py @@ -0,0 +1,53 @@ +from django.forms import TextInput, EmailInput +from django.contrib.auth.forms import UserCreationForm, UserChangeForm +from django.contrib.auth.models import User +from django.utils.translation import gettext as _ + + +class CreateUserForm(UserCreationForm): + class Meta: + model = User + fields = ['username', 'email', 'first_name', 'last_name', 'password1', 'password2'] + widgets = { + 'username': TextInput(attrs={ + 'class': 'form-control', + 'placeholder': _('Enter your username') + }), + 'email': EmailInput(attrs={ + 'class': 'form-control', + 'placeholder': _('Enter your e-mail') + }), + 'first_name': TextInput(attrs={ + 'class': 'form-control', + 'placeholder': _('Enter your first name') + }), + 'last_name': TextInput(attrs={ + 'class': 'form-control', + 'placeholder': _('Enter your last name') + }), + } + + +class UpdateUserForm(UserChangeForm): + class Meta: + model = User + fields = ['username', 'email', 'first_name', 'last_name'] + widgets = { + 'username': TextInput(attrs={ + 'class': 'form-control', + 'placeholder': _('Enter your username'), + 'readonly': True + }), + 'email': EmailInput(attrs={ + 'class': 'form-control', + 'placeholder': _('Enter your e-mail') + }), + 'first_name': TextInput(attrs={ + 'class': 'form-control', + 'placeholder': _('Enter your first name') + }), + 'last_name': TextInput(attrs={ + 'class': 'form-control', + 'placeholder': _('Enter your last name') + }), + } diff --git a/app/core/locale/es/LC_MESSAGES/django.po b/app/core/locale/es/LC_MESSAGES/django.po new file mode 100644 index 0000000..cb1a883 --- /dev/null +++ b/app/core/locale/es/LC_MESSAGES/django.po @@ -0,0 +1,547 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-09-24 02:18+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: decorators.py:26 decorators.py:30 +msgid "You do not have permission to access the requested page " +msgstr "No tienes permiso para acceder a la página solicitada " + +#: forms.py:14 forms.py:38 templates/accounts/login.html:19 +#: templates/accounts/register.html:19 +msgid "Enter your username" +msgstr "Ingrese su nombre de usuario" + +#: forms.py:18 forms.py:43 +#: templates/accounts/password_reset/password_reset.html:18 +#: templates/accounts/register.html:23 templates/core/user_profile_edit.html:22 +msgid "Enter your e-mail" +msgstr "Ingrese su correo electrónico" + +#: forms.py:22 forms.py:47 templates/accounts/register.html:27 +#: templates/core/user_profile_edit.html:26 +msgid "Enter your first name" +msgstr "Ingrese su nombre" + +#: forms.py:26 forms.py:51 templates/accounts/register.html:31 +#: templates/core/user_profile_edit.html:30 +msgid "Enter your last name" +msgstr "Ingrese su nombre de familia" + +#: models.py:16 +msgid "Received" +msgstr "Recebió" + +#: models.py:17 +msgid "Queued for validation" +msgstr "Programado para validación" + +#: models.py:18 +msgid "Validating" +msgstr "Validando" + +#: models.py:19 +msgid "Validation failure" +msgstr "Validación fallida" + +#: models.py:20 +msgid "Validated" +msgstr "Validado" + +#: models.py:34 +msgid "Initiated" +msgstr "Empezado" + +#: models.py:35 +msgid "Completed" +msgstr "Terminado" + +#: models.py:36 +msgid "Failed" +msgstr "Fallido" + +#: models.py:39 +msgid "Retrieve package" +msgstr "Recibir paquete" + +#: models.py:40 templates/core/user_package_upload.html:5 +#: templates/core/user_package_upload.html:9 +#: templates/core/user_package_upload.html:18 templates/index.html:41 +msgid "Upload package" +msgstr "Enviar paquete" + +#: models.py:41 +msgid "Start validation" +msgstr "Empezar validación" + +#: models.py:42 +msgid "Finalize validation" +msgstr "Finalizar validación" + +#: models.py:43 +msgid "Change user groups" +msgstr "Cambiar grupos de usuarios" + +#: templates/accounts/add.html:7 templates/accounts/add.html:46 +#: templates/accounts/password_reset/password_reset_complete.html:7 +#: templates/accounts/password_reset/password_reset_confirm.html:7 +#: templates/accounts/password_reset/password_reset_done.html:7 +#: templates/accounts/register.html:41 templates/index.html:82 +msgid "Add user" +msgstr "Agregar usuario" + +#: templates/accounts/add.html:18 templates/accounts/login.html:18 +#: templates/accounts/register.html:18 +#: templates/core/deposited_package_list.html:19 +#: templates/core/event_list.html:20 templates/core/user_groups_edit.html:21 +#: templates/core/user_profile.html:18 templates/core/user_profile_edit.html:17 +msgid "Username" +msgstr "Usuario" + +#: templates/accounts/add.html:19 +msgid "Enter the username" +msgstr "Ingrese el nombre de usuario" + +#: templates/accounts/add.html:23 +msgid "Enter the user e-mail" +msgstr "Introduzca el correo electrónico del usuario" + +#: templates/accounts/add.html:26 templates/accounts/login.html:22 +#: templates/accounts/register.html:34 +msgid "Password" +msgstr "Contraseña" + +#: templates/accounts/add.html:27 +msgid "Enter the user password" +msgstr "Introduzca la contraseña de usuario" + +#: templates/accounts/add.html:30 +msgid "Confirm the password" +msgstr "Confirma la contraseña" + +#: templates/accounts/add.html:31 +msgid "Re-enter the user password" +msgstr "Vuelva a introducir la contraseña de usuario" + +#: templates/accounts/add.html:34 templates/core/user_profile.html:23 +msgid "Groups" +msgstr "Grupos" + +#: templates/accounts/change_password.html:7 +#: templates/accounts/change_password.html:12 +#: templates/accounts/change_password.html:27 templates/base.html:41 +#: templates/index.html:28 +msgid "Change password" +msgstr "Cambiar contraseña" + +#: templates/accounts/change_password.html:16 +msgid "Old password" +msgstr "Contraseña anterior" + +#: templates/accounts/change_password.html:17 +msgid "Enter your old password" +msgstr "Introduzca su contraseña anterior" + +#: templates/accounts/change_password.html:20 +msgid "New password" +msgstr "Nueva contraseña" + +#: templates/accounts/change_password.html:21 +msgid "Enter your new password" +msgstr "Introduzca su nueva contraseña" + +#: templates/accounts/change_password.html:24 +msgid "Confirm new password" +msgstr "Introduzca su nueva contraseña" + +#: templates/accounts/change_password.html:25 +msgid "Re-enter your new password" +msgstr "Vuelva a introducir su nueva contraseña" + +#: templates/accounts/login.html:7 templates/accounts/login.html:25 +#: templates/accounts/register.html:44 templates/base.html:48 +msgid "Login" +msgstr "Iniciar sesión" + +#: templates/accounts/login.html:23 templates/accounts/register.html:35 +msgid "Enter your password" +msgstr "Introduzca su contraseña" + +#: templates/accounts/login.html:27 +msgid "Don't have an account" +msgstr "No tienes una cuenta" + +#: templates/accounts/login.html:27 templates/accounts/register.html:7 +#: templates/base.html:51 +msgid "Sign up" +msgstr "Registrarse" + +#: templates/accounts/password_reset/password_reset.html:7 +#: templates/accounts/password_reset/password_reset.html:12 +msgid "Reset password" +msgstr "Restablecer la contraseña" + +#: templates/accounts/password_reset/password_reset.html:20 +msgid "Send e-mail" +msgstr "Enviar correo electrónico" + +#: templates/accounts/register.html:26 templates/core/user_groups_edit.html:22 +#: templates/core/user_profile.html:19 templates/core/user_profile_edit.html:25 +msgid "First name" +msgstr "Nombre" + +#: templates/accounts/register.html:30 templates/core/user_groups_edit.html:23 +#: templates/core/user_profile.html:20 templates/core/user_profile_edit.html:29 +msgid "Last name" +msgstr "Nombre de familia" + +#: templates/accounts/register.html:38 +msgid "Confirm your password" +msgstr "Introduzca su contraseña" + +#: templates/accounts/register.html:39 +msgid "Re-enter your password" +msgstr "Vuelva a introducir su contraseña" + +#: templates/accounts/register.html:44 +msgid "Already have an account" +msgstr "Ya tengo una cuenta" + +#: templates/base.html:26 templates/core/journal_list.html:5 +#: templates/core/journal_list.html:9 +msgid "Journals" +msgstr "Revistas" + +#: templates/base.html:38 templates/core/event_list.html:6 +#: templates/core/event_list.html:10 templates/index.html:19 +msgid "Events" +msgstr "Eventos" + +#: templates/base.html:39 templates/core/user_profile.html:6 +#: templates/core/user_profile.html:10 templates/index.html:26 +msgid "Profile" +msgstr "Perfil" + +#: templates/base.html:40 templates/core/user_profile_edit.html:7 +#: templates/core/user_profile_edit.html:11 templates/index.html:27 +msgid "Edit profile" +msgstr "Editar perfil" + +#: templates/base.html:43 +msgid "Logout" +msgstr "Salir" + +#: templates/core/article_files_list.html:5 +#: templates/core/article_files_list.html:9 templates/index.html:70 +msgid "Articles' files" +msgstr "Archivos de artículos" + +#: templates/core/article_files_list.html:18 +msgid "Identifier" +msgstr "Identificador" + +#: templates/core/article_files_list.html:19 +#: templates/core/user_package_download.html:41 +msgid "Creation date" +msgstr "Fecha de criación" + +#: templates/core/article_files_list.html:20 +#: templates/core/user_package_download.html:42 +msgid "Update date" +msgstr "Fecha de actualización" + +#: templates/core/article_files_list.html:21 +#: templates/core/deposited_package_list.html:20 +#: templates/core/user_package_download.html:39 +msgid "Package name" +msgstr "Nombre del paquete" + +#: templates/core/article_files_list.html:22 +msgid "XML" +msgstr "" + +#: templates/core/article_files_list.html:23 +msgid "Assets" +msgstr "" + +#: templates/core/article_files_list.html:24 +msgid "Renditions" +msgstr "" + +#: templates/core/article_files_list.html:54 +#: templates/core/deposited_package_list.html:45 +#: templates/core/event_list.html:55 templates/core/journal_list.html:46 +#: templates/core/user_groups_edit.html:63 +msgid "First" +msgstr "Primero" + +#: templates/core/article_files_list.html:58 +#: templates/core/deposited_package_list.html:49 +#: templates/core/event_list.html:59 templates/core/journal_list.html:50 +#: templates/core/user_groups_edit.html:67 +msgid "Previous" +msgstr "Anterior" + +#: templates/core/article_files_list.html:63 +#: templates/core/deposited_package_list.html:54 +#: templates/core/event_list.html:64 templates/core/journal_list.html:55 +#: templates/core/user_groups_edit.html:72 +msgid "Page" +msgstr "Página" + +#: templates/core/article_files_list.html:63 +#: templates/core/deposited_package_list.html:54 +#: templates/core/event_list.html:64 templates/core/journal_list.html:55 +#: templates/core/user_groups_edit.html:72 +msgid "of" +msgstr "de" + +#: templates/core/article_files_list.html:68 +#: templates/core/deposited_package_list.html:59 +#: templates/core/event_list.html:69 templates/core/journal_list.html:60 +#: templates/core/user_groups_edit.html:77 +msgid "Next" +msgstr "Seguiente" + +#: templates/core/article_files_list.html:71 +#: templates/core/deposited_package_list.html:62 +#: templates/core/event_list.html:72 templates/core/journal_list.html:63 +#: templates/core/user_groups_edit.html:80 +msgid "Last" +msgstr "Último" + +#: templates/core/deposited_package_list.html:6 +#: templates/core/deposited_package_list.html:10 templates/index.html:21 +msgid "Deposited packages" +msgstr "Fecha de deposito" + +#: templates/core/deposited_package_list.html:21 +msgid "Datetime" +msgstr "Fecha y hora" + +#: templates/core/deposited_package_list.html:22 +#: templates/core/event_list.html:24 +msgid "Status" +msgstr "Estado" + +#: templates/core/event_list.html:22 +msgid "Activity" +msgstr "Actividad" + +#: templates/core/event_list.html:23 +msgid "Annotation" +msgstr "Anotación" + +#: templates/core/event_list.html:25 +msgid "Timestamp" +msgstr "Fecha y hora" + +#: templates/core/journal_list.html:18 +msgid "Title" +msgstr "Título" + +#: templates/core/journal_list.html:19 +msgid "Short title" +msgstr "Título corto" + +#: templates/core/journal_list.html:20 +msgid "Acronym" +msgstr "Acrónimo" + +#: templates/core/journal_list.html:21 +msgid "Print ISSN" +msgstr "Print ISSN" + +#: templates/core/journal_list.html:22 +msgid "Online ISSN" +msgstr "Online ISSN" + +#: templates/core/user_groups_edit.html:6 +#: templates/core/user_groups_edit.html:10 templates/index.html:83 +msgid "User groups" +msgstr "Grupos de usuarios" + +#: templates/core/user_groups_edit.html:24 templates/core/user_profile.html:21 +msgid "E-mail" +msgstr "E-mail" + +#: templates/core/user_groups_edit.html:54 +msgid "Update users' groups" +msgstr "Actualizar grupos de usuarios" + +#: templates/core/user_package_download.html:6 +#: templates/core/user_package_download.html:10 +#: templates/core/user_package_download.html:16 templates/index.html:40 +msgid "Search package" +msgstr "Buscar paquete" + +#: templates/core/user_package_download.html:22 +msgid "Document identifier" +msgstr "Identificador de documento" + +#: templates/core/user_package_download.html:23 +msgid "Enter a document identifier" +msgstr "Ingrese un identificador de documento " + +#: templates/core/user_package_download.html:25 +msgid "Search" +msgstr "Buscar" + +#: templates/core/user_package_download.html:33 +msgid "Results for document" +msgstr "Resultados del documento" + +#: templates/core/user_package_download.html:40 +#, fuzzy +#| msgid "Packages" +msgid "Package address" +msgstr "Direción del paquete" + +#: templates/core/user_package_upload.html:21 +msgid "Upload" +msgstr "Cargar" + +#: templates/core/user_profile.html:15 +msgid "User profile" +msgstr "Perfil del usuario" + +#: templates/core/user_profile.html:22 +msgid "Last login date" +msgstr "Última fecha de inicio de sesión" + +#: templates/core/user_profile_edit.html:32 +msgid "Update user" +msgstr "Actualizar usuario" + +#: templates/faq.html:5 templates/faq.html:10 +msgid "Frequently asked questions" +msgstr "Preguntas más frecuentes" + +#: templates/index.html:10 +msgid "Home" +msgstr "Inicio" + +#: templates/index.html:16 +msgid "My space" +msgstr "Mi spacio" + +#: templates/index.html:24 +msgid "Migrated data" +msgstr "Datos migrados" + +#: templates/index.html:37 +msgid "Ingress" +msgstr "Entrada" + +#: templates/index.html:51 +msgid "Migration" +msgstr "Migración" + +#: templates/index.html:54 +msgid "Migrate title" +msgstr "Migrar título" + +#: templates/index.html:55 +msgid "Migrate fascicle" +msgstr "Migrar asunto" + +#: templates/index.html:56 +msgid "Migrate document" +msgstr "Migrar documento" + +#: templates/index.html:66 +msgid "Package management" +msgstr "Gestión de paquetes" + +#: templates/index.html:69 +msgid "All deposited packages" +msgstr "Todos los paquetes depositados" + +#: templates/index.html:78 +msgid "User management" +msgstr "Gestión de usuarios" + +#: templates/index.html:81 +msgid "All events" +msgstr "Todos los eventos" + +#: templatetags/spf_extras.py:29 +msgid "Q. Analyst" +msgstr "An. de Calidad" + +#: templatetags/spf_extras.py:31 +msgid "Op. Ingress" +msgstr "Op. de Entrada" + +#: templatetags/spf_extras.py:33 +msgid "Op. Migration" +msgstr "Op. de Migración" + +#: templatetags/spf_extras.py:35 +msgid "Manager" +msgstr "Gerente" + +#: views.py:41 +#, python-format +msgid "User %s was updated" +msgstr "Se creó el usuario %s" + +#: views.py:67 views.py:151 +#, python-format +msgid "User %s was created" +msgstr "Se creó el usuario %s" + +#: views.py:97 +msgid "Incorrect username or password" +msgstr "Nombre de usuario o contraseña incorrecta." + +#: views.py:114 +msgid "Your password was updated" +msgstr "Su contraseña ha sido actualizada" + +#: views.py:233 +#, python-format +msgid "Errors ocurred: %s" +msgstr "Ocurrieron errores: %s" + +#: views.py:240 +#, python-format +msgid "Package (%(name)s, %(id)s) was added" +msgstr "Se agregó el paquete (%(name)s, %(id)s)" + +#: views.py:250 +msgid " does not have a valid format. Please provide a zip file." +msgstr " no tiene un formato válido. Por favor, proporcione un archivo zip." + +#: views.py:280 +#, python-format +msgid "No packages were found for document %s" +msgstr "No se encontraron paquetes para el documento %s" + +#: views.py:306 +msgid "Users' groups were updated" +msgstr "Se actualizaron los grupos de usuarios" + +#~ msgid "Activities" +#~ msgstr "Actividades" + +#~ msgid "All activities" +#~ msgstr "Todas las actividades" + +#~ msgid "The two password fields didn’t match." +#~ msgstr "Los dos campos de contraseña no coincidían." diff --git a/app/core/locale/pt/LC_MESSAGES/django.po b/app/core/locale/pt/LC_MESSAGES/django.po new file mode 100644 index 0000000..bac2988 --- /dev/null +++ b/app/core/locale/pt/LC_MESSAGES/django.po @@ -0,0 +1,546 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-09-24 02:18+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: decorators.py:26 decorators.py:30 +msgid "You do not have permission to access the requested page " +msgstr "Você não possui permissão para acessar a página requisitada " + +#: forms.py:14 forms.py:38 templates/accounts/login.html:19 +#: templates/accounts/register.html:19 +msgid "Enter your username" +msgstr "Digite seu nome de usuário" + +#: forms.py:18 forms.py:43 +#: templates/accounts/password_reset/password_reset.html:18 +#: templates/accounts/register.html:23 templates/core/user_profile_edit.html:22 +msgid "Enter your e-mail" +msgstr "Digite seu e-mail" + +#: forms.py:22 forms.py:47 templates/accounts/register.html:27 +#: templates/core/user_profile_edit.html:26 +msgid "Enter your first name" +msgstr "Digite seu nome" + +#: forms.py:26 forms.py:51 templates/accounts/register.html:31 +#: templates/core/user_profile_edit.html:30 +msgid "Enter your last name" +msgstr "Digite seu sobrenome" + +#: models.py:16 +msgid "Received" +msgstr "Recebido" + +#: models.py:17 +msgid "Queued for validation" +msgstr "Agendado para validação" + +#: models.py:18 +msgid "Validating" +msgstr "Validando" + +#: models.py:19 +msgid "Validation failure" +msgstr "Validação falhou" + +#: models.py:20 +msgid "Validated" +msgstr "Validado" + +#: models.py:34 +msgid "Initiated" +msgstr "Iniciado" + +#: models.py:35 +msgid "Completed" +msgstr "Completado" + +#: models.py:36 +msgid "Failed" +msgstr "Falhou" + +#: models.py:39 +msgid "Retrieve package" +msgstr "Procurar pacote" + +#: models.py:40 templates/core/user_package_upload.html:5 +#: templates/core/user_package_upload.html:9 +#: templates/core/user_package_upload.html:18 templates/index.html:41 +msgid "Upload package" +msgstr "Enviar pacote" + +#: models.py:41 +msgid "Start validation" +msgstr "Iniciar validação" + +#: models.py:42 +msgid "Finalize validation" +msgstr "Finalizar validação" + +#: models.py:43 +msgid "Change user groups" +msgstr "Alterar grupos de usuários" + +#: templates/accounts/add.html:7 templates/accounts/add.html:46 +#: templates/accounts/password_reset/password_reset_complete.html:7 +#: templates/accounts/password_reset/password_reset_confirm.html:7 +#: templates/accounts/password_reset/password_reset_done.html:7 +#: templates/accounts/register.html:41 templates/index.html:82 +msgid "Add user" +msgstr "Adicionar usuário" + +#: templates/accounts/add.html:18 templates/accounts/login.html:18 +#: templates/accounts/register.html:18 +#: templates/core/deposited_package_list.html:19 +#: templates/core/event_list.html:20 templates/core/user_groups_edit.html:21 +#: templates/core/user_profile.html:18 templates/core/user_profile_edit.html:17 +msgid "Username" +msgstr "Usuário" + +#: templates/accounts/add.html:19 +msgid "Enter the username" +msgstr "Digite o nome de usuário" + +#: templates/accounts/add.html:23 +msgid "Enter the user e-mail" +msgstr "Digite o e-mail" + +#: templates/accounts/add.html:26 templates/accounts/login.html:22 +#: templates/accounts/register.html:34 +msgid "Password" +msgstr "Senha" + +#: templates/accounts/add.html:27 +msgid "Enter the user password" +msgstr "Digite a senha" + +#: templates/accounts/add.html:30 +msgid "Confirm the password" +msgstr "Confirme a senha" + +#: templates/accounts/add.html:31 +msgid "Re-enter the user password" +msgstr "Digita a senha novamente" + +#: templates/accounts/add.html:34 templates/core/user_profile.html:23 +msgid "Groups" +msgstr "Grupos" + +#: templates/accounts/change_password.html:7 +#: templates/accounts/change_password.html:12 +#: templates/accounts/change_password.html:27 templates/base.html:41 +#: templates/index.html:28 +msgid "Change password" +msgstr "Alterar senha" + +#: templates/accounts/change_password.html:16 +msgid "Old password" +msgstr "Senha antiga" + +#: templates/accounts/change_password.html:17 +msgid "Enter your old password" +msgstr "Digite sua senha antiga" + +#: templates/accounts/change_password.html:20 +msgid "New password" +msgstr "Senha nova" + +#: templates/accounts/change_password.html:21 +msgid "Enter your new password" +msgstr "Digita sua senha nova" + +#: templates/accounts/change_password.html:24 +msgid "Confirm new password" +msgstr "Confirme sua senha nova" + +#: templates/accounts/change_password.html:25 +msgid "Re-enter your new password" +msgstr "Digite sua senha nova novamente" + +#: templates/accounts/login.html:7 templates/accounts/login.html:25 +#: templates/accounts/register.html:44 templates/base.html:48 +msgid "Login" +msgstr "Entrar" + +#: templates/accounts/login.html:23 templates/accounts/register.html:35 +msgid "Enter your password" +msgstr "Digite sua senha" + +#: templates/accounts/login.html:27 +msgid "Don't have an account" +msgstr "Não possui uma conta" + +#: templates/accounts/login.html:27 templates/accounts/register.html:7 +#: templates/base.html:51 +msgid "Sign up" +msgstr "Registrar-se" + +#: templates/accounts/password_reset/password_reset.html:7 +#: templates/accounts/password_reset/password_reset.html:12 +msgid "Reset password" +msgstr "Redefinir senha" + +#: templates/accounts/password_reset/password_reset.html:20 +msgid "Send e-mail" +msgstr "Enviar e-mail" + +#: templates/accounts/register.html:26 templates/core/user_groups_edit.html:22 +#: templates/core/user_profile.html:19 templates/core/user_profile_edit.html:25 +msgid "First name" +msgstr "Nome" + +#: templates/accounts/register.html:30 templates/core/user_groups_edit.html:23 +#: templates/core/user_profile.html:20 templates/core/user_profile_edit.html:29 +msgid "Last name" +msgstr "Sobrenome" + +#: templates/accounts/register.html:38 +msgid "Confirm your password" +msgstr "Confirme sua senha" + +#: templates/accounts/register.html:39 +msgid "Re-enter your password" +msgstr "Digite sua senha novamente" + +#: templates/accounts/register.html:44 +msgid "Already have an account" +msgstr "Já possui uma conta" + +#: templates/base.html:26 templates/core/journal_list.html:5 +#: templates/core/journal_list.html:9 +msgid "Journals" +msgstr "Periódicos" + +#: templates/base.html:38 templates/core/event_list.html:6 +#: templates/core/event_list.html:10 templates/index.html:19 +msgid "Events" +msgstr "Ações" + +#: templates/base.html:39 templates/core/user_profile.html:6 +#: templates/core/user_profile.html:10 templates/index.html:26 +msgid "Profile" +msgstr "Perfil" + +#: templates/base.html:40 templates/core/user_profile_edit.html:7 +#: templates/core/user_profile_edit.html:11 templates/index.html:27 +msgid "Edit profile" +msgstr "Editar perfil" + +#: templates/base.html:43 +msgid "Logout" +msgstr "Sair" + +#: templates/core/article_files_list.html:5 +#: templates/core/article_files_list.html:9 templates/index.html:70 +msgid "Articles' files" +msgstr "Arquivos de artigos" + +#: templates/core/article_files_list.html:18 +msgid "Identifier" +msgstr "Identificador de documento" + +#: templates/core/article_files_list.html:19 +#: templates/core/user_package_download.html:41 +msgid "Creation date" +msgstr "Data de criação" + +#: templates/core/article_files_list.html:20 +#: templates/core/user_package_download.html:42 +msgid "Update date" +msgstr "Data de atualização" + +#: templates/core/article_files_list.html:21 +#: templates/core/deposited_package_list.html:20 +#: templates/core/user_package_download.html:39 +msgid "Package name" +msgstr "Nome do pacote" + +#: templates/core/article_files_list.html:22 +msgid "XML" +msgstr "" + +#: templates/core/article_files_list.html:23 +msgid "Assets" +msgstr "" + +#: templates/core/article_files_list.html:24 +msgid "Renditions" +msgstr "" + +#: templates/core/article_files_list.html:54 +#: templates/core/deposited_package_list.html:45 +#: templates/core/event_list.html:55 templates/core/journal_list.html:46 +#: templates/core/user_groups_edit.html:63 +msgid "First" +msgstr "Primeiro" + +#: templates/core/article_files_list.html:58 +#: templates/core/deposited_package_list.html:49 +#: templates/core/event_list.html:59 templates/core/journal_list.html:50 +#: templates/core/user_groups_edit.html:67 +msgid "Previous" +msgstr "Anterior" + +#: templates/core/article_files_list.html:63 +#: templates/core/deposited_package_list.html:54 +#: templates/core/event_list.html:64 templates/core/journal_list.html:55 +#: templates/core/user_groups_edit.html:72 +msgid "Page" +msgstr "Página" + +#: templates/core/article_files_list.html:63 +#: templates/core/deposited_package_list.html:54 +#: templates/core/event_list.html:64 templates/core/journal_list.html:55 +#: templates/core/user_groups_edit.html:72 +msgid "of" +msgstr "de" + +#: templates/core/article_files_list.html:68 +#: templates/core/deposited_package_list.html:59 +#: templates/core/event_list.html:69 templates/core/journal_list.html:60 +#: templates/core/user_groups_edit.html:77 +msgid "Next" +msgstr "Próximo" + +#: templates/core/article_files_list.html:71 +#: templates/core/deposited_package_list.html:62 +#: templates/core/event_list.html:72 templates/core/journal_list.html:63 +#: templates/core/user_groups_edit.html:80 +msgid "Last" +msgstr "Último" + +#: templates/core/deposited_package_list.html:6 +#: templates/core/deposited_package_list.html:10 templates/index.html:21 +msgid "Deposited packages" +msgstr "Pacotes depositados" + +#: templates/core/deposited_package_list.html:21 +msgid "Datetime" +msgstr "Data e hora" + +#: templates/core/deposited_package_list.html:22 +#: templates/core/event_list.html:24 +msgid "Status" +msgstr "Estado" + +#: templates/core/event_list.html:22 +msgid "Activity" +msgstr "Atividade" + +#: templates/core/event_list.html:23 +msgid "Annotation" +msgstr "Anotação" + +#: templates/core/event_list.html:25 +msgid "Timestamp" +msgstr "Data e hora" + +#: templates/core/journal_list.html:18 +msgid "Title" +msgstr "Título" + +#: templates/core/journal_list.html:19 +msgid "Short title" +msgstr "Título abreviado" + +#: templates/core/journal_list.html:20 +msgid "Acronym" +msgstr "Acrônimo" + +#: templates/core/journal_list.html:21 +msgid "Print ISSN" +msgstr "Print ISSN" + +#: templates/core/journal_list.html:22 +msgid "Online ISSN" +msgstr "Online ISSN" + +#: templates/core/user_groups_edit.html:6 +#: templates/core/user_groups_edit.html:10 templates/index.html:83 +msgid "User groups" +msgstr "Grupos de usuário" + +#: templates/core/user_groups_edit.html:24 templates/core/user_profile.html:21 +msgid "E-mail" +msgstr "E-mail" + +#: templates/core/user_groups_edit.html:54 +msgid "Update users' groups" +msgstr "Atualizar grupos de usuários" + +#: templates/core/user_package_download.html:6 +#: templates/core/user_package_download.html:10 +#: templates/core/user_package_download.html:16 templates/index.html:40 +msgid "Search package" +msgstr "Procurar pacote" + +#: templates/core/user_package_download.html:22 +msgid "Document identifier" +msgstr "Identificador de documento" + +#: templates/core/user_package_download.html:23 +msgid "Enter a document identifier" +msgstr "Digite um identificador de documento" + +#: templates/core/user_package_download.html:25 +msgid "Search" +msgstr "Procurar" + +#: templates/core/user_package_download.html:33 +msgid "Results for document" +msgstr "Resultados para o documento" + +#: templates/core/user_package_download.html:40 +msgid "Package address" +msgstr "Endereço do pacote" + +#: templates/core/user_package_upload.html:21 +msgid "Upload" +msgstr "Enviar" + +#: templates/core/user_profile.html:15 +msgid "User profile" +msgstr "Editar perfil" + +#: templates/core/user_profile.html:22 +msgid "Last login date" +msgstr "Data do último acesso" + +#: templates/core/user_profile_edit.html:32 +msgid "Update user" +msgstr "Atualizar usuário" + +#: templates/faq.html:5 templates/faq.html:10 +msgid "Frequently asked questions" +msgstr "Perguntas frequentes" + +#: templates/index.html:10 +msgid "Home" +msgstr "Início" + +#: templates/index.html:16 +msgid "My space" +msgstr "Meu espaço" + +#: templates/index.html:24 +msgid "Migrated data" +msgstr "Dados migrados" + +#: templates/index.html:37 +msgid "Ingress" +msgstr "Ingresso" + +#: templates/index.html:51 +msgid "Migration" +msgstr "Migração" + +#: templates/index.html:54 +msgid "Migrate title" +msgstr "Migrar periódico" + +#: templates/index.html:55 +msgid "Migrate fascicle" +msgstr "Migrar fascículo" + +#: templates/index.html:56 +msgid "Migrate document" +msgstr "Migrar artigo" + +#: templates/index.html:66 +msgid "Package management" +msgstr "Gerenciamento de pacotes" + +#: templates/index.html:69 +msgid "All deposited packages" +msgstr "Todo os pacotes depositados" + +#: templates/index.html:78 +msgid "User management" +msgstr "Gerenciamento de usuário" + +#: templates/index.html:81 +msgid "All events" +msgstr "Todas as ações" + +#: templatetags/spf_extras.py:29 +msgid "Q. Analyst" +msgstr "An. de Qualidade" + +#: templatetags/spf_extras.py:31 +msgid "Op. Ingress" +msgstr "Op. de Ingresso" + +#: templatetags/spf_extras.py:33 +msgid "Op. Migration" +msgstr "Op. de Migração" + +#: templatetags/spf_extras.py:35 +msgid "Manager" +msgstr "Gerente" + +#: views.py:41 +#, python-format +msgid "User %s was updated" +msgstr "Usuário %s foi atualizado" + +#: views.py:67 views.py:151 +#, python-format +msgid "User %s was created" +msgstr "Usuário %s foi criado" + +#: views.py:97 +msgid "Incorrect username or password" +msgstr "Nome de usuário ou senha incorreto" + +#: views.py:114 +msgid "Your password was updated" +msgstr "Sua senha foi atualizada" + +#: views.py:233 +#, python-format +msgid "Errors ocurred: %s" +msgstr "Ocorreram erros: %s" + +#: views.py:240 +#, python-format +msgid "Package (%(name)s, %(id)s) was added" +msgstr "Pacote (%(name)s, %(id)s) foi adicionado" + +#: views.py:250 +msgid " does not have a valid format. Please provide a zip file." +msgstr "" +" não possui um formato válido. Por favor, forneça um arquivo em formato zip." + +#: views.py:280 +#, python-format +msgid "No packages were found for document %s" +msgstr "Não foram encontrados pacotes para o documento %s" + +#: views.py:306 +msgid "Users' groups were updated" +msgstr "Grupos de usuários foram atualizados" + +#~ msgid "Activities" +#~ msgstr "Atividades" + +#~ msgid "All activities" +#~ msgstr "Todas as atividades" + +#~ msgid "The two password fields didn’t match." +#~ msgstr "As duas senhas são diferentes." diff --git a/app/core/management/commands/make_messages_no_fuzzy.py b/app/core/management/commands/make_messages_no_fuzzy.py new file mode 100644 index 0000000..0e46501 --- /dev/null +++ b/app/core/management/commands/make_messages_no_fuzzy.py @@ -0,0 +1,5 @@ +from django.core.management.commands import makemessages + + +class Command(makemessages.Command): + msgmerge_options = ['-q', '--previous', '--no-fuzzy-matching'] diff --git a/app/core/migrations/__init__.py b/app/core/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/core/models.py b/app/core/models.py new file mode 100644 index 0000000..d50e325 --- /dev/null +++ b/app/core/models.py @@ -0,0 +1,67 @@ +from django.db import models +from django.contrib.auth.models import User +from django.utils.translation import gettext_lazy as _ + + +GROUP_MANAGER = 'manager' +GROUP_OPERATOR_INGRESS = 'operator_ingress' +GROUP_OPERATOR_MIGRATION = 'operator_migration' +GROUP_QUALITY_ANALYST = 'quality_analyst' + +SCOPE_ALL_USERS = 'all_users' + + +class IngressPackage(models.Model): + class Status(models.TextChoices): + RECEIVED = 'R', _('Received') + QUEUDED_FOR_VALIDATION = 'Q', _('Queued for validation') + VALIDATING = 'D', _('Validating') + VALIDATION_FAILURE = 'F', _('Validation failure') + VALIDATED = 'V', _('Validated') + + user = models.ForeignKey(User, on_delete=models.PROTECT) + package_name = models.CharField(max_length=200) + datetime = models.DateTimeField() + status = models.CharField(max_length=1, choices=Status.choices, blank=False, null=False) + + +class MigratePackage(models.Model): + ... + + +class Event(models.Model): + class Status(models.TextChoices): + INITIATED = 'I', _('Initiated') + COMPLETED = 'C', _('Completed') + FAILED = 'F', _('Failed') + + class Name(models.TextChoices): + RETRIEVE_PACKAGE = 'RP', _('Retrieve package') + UPLOAD_PACKAGE = 'UP', _('Upload package') + START_VALIDATION = 'SV', _('Start validation') + FINALIZE_VALIDATION = 'FV', _('Finalize validation') + CHANGE_USER_GROUPS = 'CUG', _('Change user groups') + + # quem realiza o evento + user = models.ForeignKey(User, on_delete=models.PROTECT) + + # momento em que o evento foi iniciado + datetime = models.DateTimeField(auto_now=True) + + # nome do evento + name = models.CharField(max_length=3, choices=Name.choices, blank=False, null=False) + + # estado do evento (iniciado, realizando, concluído) + status = models.CharField(max_length=1, choices=Status.choices, blank=False, null=False) + + # informação relacionada ao evento + annotation = models.CharField(max_length=200, null=True) + + +class ValidationSchema(models.Model): + schema_name = models.CharField(max_length=200, null=True) + + +class Validation(models.Model): + name = models.CharField(max_length=200, null=True) + validation_schema = models.ForeignKey(ValidationSchema, on_delete=models.PROTECT) diff --git a/app/core/static/css/style.css b/app/core/static/css/style.css new file mode 100644 index 0000000..5bbfb99 --- /dev/null +++ b/app/core/static/css/style.css @@ -0,0 +1,10 @@ +.form-user { + width: 100%; + max-width: 400px; + padding: 0; + margin: 0 auto; +} + +.is-no-rounded { + border-radius: 0; +} diff --git a/app/core/static/img/logo-scielo.svg b/app/core/static/img/logo-scielo.svg new file mode 100644 index 0000000..672fc14 --- /dev/null +++ b/app/core/static/img/logo-scielo.svg @@ -0,0 +1 @@ +logo-scielo-portal-no-label-2 \ No newline at end of file diff --git a/app/core/static/js/main.js b/app/core/static/js/main.js new file mode 100644 index 0000000..33d6c43 --- /dev/null +++ b/app/core/static/js/main.js @@ -0,0 +1,65 @@ +function createMessage(msg){ + divAlert = document.createElement('div'); + divAlert.classList.add('alert', 'alert-danger', 'alert-dismissible', 'fade', 'show', 'is-no-rounded', 'm-0', 'p-2'); + divAlert.setAttribute('role', 'alert'); + + divContainer = document.createElement('div'); + divContainer.classList.add('container', 'text-center'); + divContainer.innerHTML = msg; + + btnClose = document.createElement('button'); + btnClose.type = 'button'; + btnClose.classList.add('btn-close', 'btn-sm', 'm-1', 'p-2'); + btnClose.setAttribute('data-bs-dismiss', 'alert'); + btnClose.setAttribute('aria-label', 'Close'); + + divContainer.appendChild(btnClose); + divAlert.appendChild(divContainer); + + return divAlert; +} + +function ingressPackageDownloadToggleSpinner(){ + var btnSearchPackage = document.getElementById('btnSearchPackage'); + var divSpinner = document.getElementById('searchPackageLoading'); + if (divSpinner.style.display == "none") { + divSpinner.style.display = 'block'; + btnSearchPackage.setAttribute('disabled', 'disabled'); + } else { + divSpinner.style.display = 'none'; + btnSearchPackage.removeAttribute('disabled'); + } +} + +function ingressPackageDownloadCreateTable(data){ + tableBody = document.getElementById('resultSearchPackagesTableBody') + + for (k in data['doc_pkgs']){ + els = data['doc_pkgs'][k]; + row = tableBody.insertRow(-1); + + aResult = document.createElement('a') + aResult.text = els['name']; + aResult.href = els['uri']; + aResult.classList.add('link'); + + tdUri = row.insertCell(-1); + tdUri.appendChild(aResult); + + tdCreated = row.insertCell(-1); + tdCreated.innerHTML = els['created']; + + tdUpdated = row.insertCell(-1); + tdUpdated.innerHTML = els['updated']; + } + + if (data['doc_pkgs'].length > 0) { + document.getElementById('resultSearchPackages').style.display = 'block'; + } else { + var divBaseMessages = document.getElementById('baseMessages'); + for (k in data['errors']){ + element_message = createMessage(data['errors'][k]); + divBaseMessages.append(element_message); + } + } +} diff --git a/app/core/tasks.py b/app/core/tasks.py new file mode 100644 index 0000000..61ac65a --- /dev/null +++ b/app/core/tasks.py @@ -0,0 +1,19 @@ +from celery import shared_task, current_task + +import dsm.ingress as dsm_ingress + + +@shared_task +def task_get_package_uri_by_pid(pid): + result = dsm_ingress.get_package_uri_by_pid(pid) + + current_task.update_state( + state='PROGRESS', + meta={ + 'status': 'LOADING...', + }) + + return result + + + diff --git a/app/core/templates/base.html b/app/core/templates/base.html new file mode 100644 index 0000000..087b995 --- /dev/null +++ b/app/core/templates/base.html @@ -0,0 +1,80 @@ + + +{% load i18n %} + + {% load static %} + {% block title %}{% endblock %} + + + + + + + + + + + + + +
+{% for message in messages %} + +{% endfor %} +
+ +
+ {% block content %} + {% endblock %} +
+ + \ No newline at end of file diff --git a/app/core/templates/faq.html b/app/core/templates/faq.html new file mode 100644 index 0000000..c8ff3a9 --- /dev/null +++ b/app/core/templates/faq.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block title %} +SciELO Publishing Framework - {% trans 'Frequently asked questions' %} +{% endblock %} + +{% block content %} +
+

{% trans 'Frequently asked questions' %}

+
+{% endblock %} diff --git a/app/core/templates/index.html b/app/core/templates/index.html new file mode 100644 index 0000000..69d4773 --- /dev/null +++ b/app/core/templates/index.html @@ -0,0 +1,109 @@ +{% extends "base.html" %} +{% load i18n %} +{% load spf_extras %} + +{% block title %} +SciELO Publishing Framework - Home +{% endblock %} + +{% block content %} +

{% trans 'Home' %}

+ {% if user.is_authenticated %} +
+
+
+
+ {% trans 'My space' %} +
+
+ {% trans 'Events' %} + {% if user.is_superuser or user|has_group:"manager" or user|has_group:"operator_ingress" %} + {% trans "Deposited packages" %} + {% endif %} + {% if user.is_superuser or user|has_group:"manager" or user|has_group:"operator_migration" %} + {% trans "Migrated data" %} + {% endif %} + {% trans 'Profile' %} + {% trans 'Edit profile' %} + {% trans 'Change password' %} +
+
+
+ + {% if user.is_superuser or user|has_group:"manager" or user|has_group:"operator_ingress" %} +
+
+
+ {% trans 'Ingress' %} +
+ +
+
+ + + + {% endif %} + + {% if user.is_superuser or user|has_group:"manager" or user|has_group:"operator_migration" %} + + {% endif %} + + {% if user.is_superuser or user|has_group:"manager" %} +
+
+
+ {% trans 'Package management' %} +
+ +
+
+ +
+
+
+ {% trans 'User management' %} +
+ +
+
+ {% endif %} + +
+ {% endif %} + +{% endblock %} diff --git a/app/core/templates/ingress/article_files_list.html b/app/core/templates/ingress/article_files_list.html new file mode 100644 index 0000000..4a9f84b --- /dev/null +++ b/app/core/templates/ingress/article_files_list.html @@ -0,0 +1,79 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block title %} +SciELO Publishing Framework - {% trans "Articles' files" %} +{% endblock %} + +{% block content %} +

{% trans "Articles' files" %}

+ +
+ {% if article_files_obj %} +
+ + + + + + + + + + + + + + + {% for art in article_files_obj %} + + + + + {% if art.created != art.updated %} + + {% else %} + + {% endif %} + + + + + + {% endfor %} + +
#{% trans 'Identifier' %}{% trans 'Creation date' %}{% trans 'Update date' %}{% trans 'Package name' %}{% trans 'XML' %}{% trans 'Assets' %}{% trans 'Renditions' %}
{{ article_files_obj.start_index|add:forloop.counter0 }}{{ art.id }}{{ art.created|date:'Y-m-d H:i' }}{{ art.updated|date:'Y-m-d H:i' }}{{ art.file.name }}{{ art.xml }}{{ art.assets|length }}{{ art.renditions|length }}
+
+ {% endif %} +
+ +{% if article_files_obj %} + +{% endif %} + +{% endblock %} \ No newline at end of file diff --git a/app/core/templates/ingress/package_download.html b/app/core/templates/ingress/package_download.html new file mode 100644 index 0000000..174e06d --- /dev/null +++ b/app/core/templates/ingress/package_download.html @@ -0,0 +1,90 @@ +{% extends "base.html" %} +{% load i18n %} +{% load spf_extras %} + +{% block title %} +SciELO Publishing Framework - {% trans 'Search package' %} +{% endblock %} + +{% block content %} +

{% trans 'Search package' %}

+ +
+
+
+
+ {% trans 'Search package' %} +
+
+
+ {% csrf_token %} +
+ + +
+ +
+
+
+ + +
+ + + +
+ +{% endblock %} \ No newline at end of file diff --git a/app/core/templates/ingress/package_list.html b/app/core/templates/ingress/package_list.html new file mode 100644 index 0000000..0498a4f --- /dev/null +++ b/app/core/templates/ingress/package_list.html @@ -0,0 +1,70 @@ +{% extends "base.html" %} +{% load i18n %} +{% load spf_extras %} + +{% block title %} +SciELO Publishing Framework - {% trans 'Deposited packages' %} +{% endblock %} + +{% block content %} +

{% trans 'Deposited packages' %}

+ +
+ {% if deposited_package_obj %} +
+ + + + + + + + + + + + {% for dpkg in deposited_package_obj %} + + + + + + + + {% endfor %} + +
#{% trans 'Username' %}{% trans 'Package name' %}{% trans 'Datetime' %}{% trans 'Status' %}
{{ deposited_package_obj.start_index|add:forloop.counter0 }}{{ dpkg.user }}{{ dpkg.package_name }}{{ dpkg.datetime|date:'Y-m-d H:i' }}{{ dpkg.get_status_display }}
+
+ {% endif %} +
+ +{% if deposited_package_obj %} + +{% endif %} + +{% endblock %} diff --git a/app/core/templates/ingress/package_upload.html b/app/core/templates/ingress/package_upload.html new file mode 100644 index 0000000..14382a7 --- /dev/null +++ b/app/core/templates/ingress/package_upload.html @@ -0,0 +1,28 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block title %} +SciELO Publishing Framework - {% trans 'Upload package' %} +{% endblock %} + +{% block content %} +

{% trans 'Upload package' %}

+ +
+
+
+
+
+ {% csrf_token %} +
+ + +
+ +
+
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/app/core/templates/journal/journal_list.html b/app/core/templates/journal/journal_list.html new file mode 100644 index 0000000..83e8827 --- /dev/null +++ b/app/core/templates/journal/journal_list.html @@ -0,0 +1,73 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block title %} +SciELO Publishing Framework - {% trans 'Journals' %} +{% endblock %} + +{% block content %} +

{% trans 'Journals' %}

+ +
+ {% if journal_obj %} +
+ + + + + + + + + + + + + + {% for jour in journal_obj %} + + + + + + + + + + {% endfor %} + +
#{% trans 'Title' %}{% trans 'Short title' %}{% trans 'Acronym' %}{% trans 'Print ISSN' %}{% trans 'Online ISSN' %}{% trans 'SciELO ISSN' %}
{{ journal_obj.start_index|add:forloop.counter0 }}{{ jour.title }}{{ jour.short_title }}{{ jour.acronym }}{{ jour.print_issn|default:'' }}{{ jour.eletronic_issn|default:'' }}{{ jour.scielo_issn|default:'' }}
+
+ {% endif %} +
+ +{% if journal_obj %} + +{% endif %} + +{% endblock %} diff --git a/app/core/templates/tracking/event_list.html b/app/core/templates/tracking/event_list.html new file mode 100644 index 0000000..8b824e6 --- /dev/null +++ b/app/core/templates/tracking/event_list.html @@ -0,0 +1,80 @@ +{% extends "base.html" %} +{% load i18n %} +{% load spf_extras %} + +{% block title %} +SciELO Publishing Framework - {% trans 'Events' %} +{% endblock %} + +{% block content %} +

{% trans 'Events' %}

+ +
+ {% if event_obj %} +
+ + + + + {% if user|has_group:"manager" %} + + {% endif %} + + + + + + + + {% for ev in event_obj %} + + + {% if user|has_group:"manager" %} + + {% if ev.annotation %} + + {% else %} + + {% endif %} + + + + {% endfor %} + +
#{% trans 'Username' %}{% trans 'Activity' %}{% trans 'Annotation' %}{% trans 'Status' %}{% trans 'Timestamp' %}
{{ event_obj.start_index|add:forloop.counter0 }}{{ ev.user }} + {% endif %} + {{ ev.get_name_display }}{{ ev.annotation }}{{ ev.get_status_display }}{{ ev.datetime }}
+
+ {% endif %} +
+ +{% if event_obj %} + +{% endif %} + +{% endblock %} \ No newline at end of file diff --git a/app/core/templates/user/add.html b/app/core/templates/user/add.html new file mode 100644 index 0000000..ab2de94 --- /dev/null +++ b/app/core/templates/user/add.html @@ -0,0 +1,49 @@ +{% extends "base.html" %} +{% load i18n %} +{% load spf_extras %} +{% load static %} + +{% block title %} +SciELO Publishing Framework - {% trans 'Add user' %} +{% endblock %} + +{% block content %} +
+ +
+

SciELO Publishing Framework

+
+ {% csrf_token %} +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + {% for g in available_groups %} +
+ {% if g.name not in user_groups %} + + {% else %} + + {% endif %} + +
+ {% endfor %} +
+ +
+ +{% endblock %} diff --git a/app/core/templates/user/change_password.html b/app/core/templates/user/change_password.html new file mode 100644 index 0000000..e94cfe3 --- /dev/null +++ b/app/core/templates/user/change_password.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} +{% load i18n %} +{% load spf_extras %} +{% load static %} + +{% block title %} +SciELO Publishing Framework - {% trans 'Change password' %} +{% endblock %} + +{% block content %} +
+

{% trans 'Change password' %}

+
+ {% csrf_token %} +
+ + +
+
+ + +
+
+ + +
+ +
+
+ +{% endblock %} diff --git a/app/core/templates/user/groups_edit.html b/app/core/templates/user/groups_edit.html new file mode 100644 index 0000000..248a558 --- /dev/null +++ b/app/core/templates/user/groups_edit.html @@ -0,0 +1,88 @@ +{% extends "base.html" %} +{% load i18n %} +{% load spf_extras %} + +{% block title %} +SciELO Publishing Framework - {% trans 'User groups' %} +{% endblock %} + +{% block content %} +

{% trans 'User groups' %}

+ +
+ {% if user_obj %} +
+ {% csrf_token %} +
+ + + + + + + + + {% for g in available_groups %} + + {% endfor %} + + + + {% for u in user_obj %} + + + + + + + {% for g in available_groups %} + + {% endfor %} + + {% endfor %} + +
#{% trans 'Username' %}{% trans 'First name' %}{% trans 'Last name' %}{% trans 'E-mail' %}{{ g.name|to_short_group_name }}
{{ user_obj.start_index|add:forloop.counter0 }}{{ u.username }}{{ u.first_name }}{{ u.last_name }}{{ u.email }} +
+ {% if u|has_group:g %} + + {% else %} + + {% endif %} +
+
+
+ +
+ {% endif %} +
+ +{% if user_obj %} + +{% endif %} + +{% endblock %} diff --git a/app/core/templates/user/login.html b/app/core/templates/user/login.html new file mode 100644 index 0000000..95cc69b --- /dev/null +++ b/app/core/templates/user/login.html @@ -0,0 +1,28 @@ +{% extends "base.html" %} +{% load i18n %} + +{% load static %} + +{% block title %} +SciELO Publishing Framework - {% trans 'Login' %} +{% endblock %} + +{% block content %} +
+ +
+

SciELO Publishing Framework

+
+ {% csrf_token %} +
+ + +
+
+ + +
+ +
+

{% trans "Don't have an account" %}?

{% trans 'Sign up' %}.
+{% endblock %} diff --git a/app/core/templates/user/profile.html b/app/core/templates/user/profile.html new file mode 100644 index 0000000..049cb72 --- /dev/null +++ b/app/core/templates/user/profile.html @@ -0,0 +1,34 @@ +{% extends "base.html" %} +{% load i18n %} +{% load spf_extras %} + +{% block title %} +SciELO Publishing Framework - {% trans 'Profile' %} +{% endblock %} + +{% block content %} +

{% trans 'Profile' %}

+ +
+
+
+
{% trans 'User profile' %}
+
+
    +
  • {% trans 'Username' %}: {{ request.user.username }}
  • +
  • {% trans 'First name' %}: {{ request.user.first_name }}
  • +
  • {% trans 'Last name' %}: {{ request.user.last_name }}
  • +
  • {% trans 'E-mail' %}: {{ request.user.email }}
  • +
  • {% trans 'Last login date' %}: {{ request.user.last_login }}
  • +
  • {% trans 'Groups' %}: + {% for g in groups %} + {{ g|to_short_group_name }} + {% endfor %} +
  • +
+
+
+
+
+ +{% endblock %} diff --git a/app/core/templates/user/profile_edit.html b/app/core/templates/user/profile_edit.html new file mode 100644 index 0000000..e21a4d1 --- /dev/null +++ b/app/core/templates/user/profile_edit.html @@ -0,0 +1,36 @@ +{% extends "base.html" %} +{% load i18n %} + +{% load static %} + +{% block title %} +SciELO Publishing Framework - {% trans 'Edit profile' %} +{% endblock %} + +{% block content %} +

{% trans 'Edit profile' %}

+ +
+
+ {% csrf_token %} +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ +{% endblock %} diff --git a/app/core/templates/user/register.html b/app/core/templates/user/register.html new file mode 100644 index 0000000..8832bc3 --- /dev/null +++ b/app/core/templates/user/register.html @@ -0,0 +1,45 @@ +{% extends "base.html" %} +{% load i18n %} + +{% load static %} + +{% block title %} +SciELO Publishing Framework - {% trans 'Sign up' %} +{% endblock %} + +{% block content %} +
+ +
+

SciELO Publishing Framework

+
+ {% csrf_token %} +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +

{% trans 'Already have an account' %}?

{% trans 'Login' %}.
+{% endblock %} diff --git a/app/core/templatetags/__init__.py b/app/core/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/core/templatetags/spf_extras.py b/app/core/templatetags/spf_extras.py new file mode 100644 index 0000000..ea00064 --- /dev/null +++ b/app/core/templatetags/spf_extras.py @@ -0,0 +1,62 @@ +from django import template +from django.contrib.auth.models import Group +from django.utils.translation import gettext as _ +from dateutil import parser + + +register = template.Library() + + +@register.filter(name='has_group') +def has_group(user, group): + group = Group.objects.get(name=group) + return group in user.groups.all() + + +@register.filter(name='to_datetime') +def to_datetime(text): + if isinstance(text, str): + try: + return parser.parse(text) + except: + pass + return text + + +@register.filter(name='to_short_group_name') +def to_short_group_name(group): + if group == 'quality_analyst': + return _('Q. Analyst') + if group == 'operator_ingress': + return _('Op. Ingress') + if group == 'operator_migration': + return _('Op. Migration') + if group == 'manager': + return _('Manager') + return group.title() + + +@register.filter(name='to_css_event_status_style') +def to_css_event_status_style(event_status): + if event_status == 'I': + return 'bg-warning' + elif event_status == 'C': + return 'bg-success' + elif event_status == 'F': + return 'bg-danger' + else: + return 'bg-secondary' + + +@register.filter(name='to_css_ingress_package_status_style') +def to_css_ingress_package_status_style(ingress_package_status): + if ingress_package_status == 'R': + return 'bg-primary' + elif ingress_package_status == 'Q': + return 'bg-secondary' + elif ingress_package_status == 'D': + return 'bg-warning' + elif ingress_package_status == 'V': + return 'bg-success' + elif ingress_package_status == 'F': + return 'bg-danger' diff --git a/app/core/tests.py b/app/core/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/app/core/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/app/core/urls.py b/app/core/urls.py new file mode 100644 index 0000000..a44d35c --- /dev/null +++ b/app/core/urls.py @@ -0,0 +1,37 @@ +from django.urls import path +from . import views + + +general = [ + path('', views.index_page, name='index'), + path('faq/', views.faq_page, name='faq'), +] + +user = [ + path('register/', views.user_register_page, name='register'), + path('login/', views.user_login_page, name='login'), + path('logout/', views.user_logout, name='logout'), + path('user/add/', views.user_add_page, name='user_add'), + path('user/change_password/', views.user_change_password_page, name='user_change_password'), + path('user/groups/edit', views.user_groups_edit_page, name='user_groups_edit'), + path('user/profile/', views.user_profile_page, name='user_profile'), + path('user/profile/edit/', views.user_profile_edit_page, name='user_profile_edit'), +] + +ingress = [ + path('ingress/package_upload/', views.ingress_package_upload_page, name='ingress_package_upload'), + path('ingress/package_download/', views.ingress_package_download_page, name='ingress_package_download'), + path('ingress/package_list/', views.ingress_package_list_page, name='ingress_package_list'), + path('ingress/articles_files/', views.ingress_articles_files_page, name='ingress_article_files_list'), +] + +journal = [ + path('journal/list/', views.journal_list_page, name='journal_list'), +] + +tracking = [ + path('event/list/', views.event_list_page, name='event_list'), + path('task/update_status/', views.task_update_status, name='task_update_status'), +] + +urlpatterns = general + user + ingress + journal + tracking \ No newline at end of file diff --git a/app/core/views.py b/app/core/views.py new file mode 100644 index 0000000..83c84af --- /dev/null +++ b/app/core/views.py @@ -0,0 +1,352 @@ +from celery.result import AsyncResult +from django.contrib import messages +from django.contrib.auth import authenticate, login, logout, update_session_auth_hash +from django.contrib.auth.decorators import login_required +from django.contrib.auth.forms import PasswordChangeForm +from django.core.files.storage import FileSystemStorage +from django.core.paginator import Paginator +from django.urls import reverse +from django.http.response import HttpResponseRedirect, JsonResponse +from django.utils.translation import gettext as _ +from django.shortcuts import render, redirect +from core.forms import CreateUserForm, UpdateUserForm +from core.decorators import unauthenticated_user, allowed_users +from core.models import Event +from core.tasks import task_get_package_uri_by_pid +from spf import settings +from os import path + +import core.controller as controller +import dsm.ingress as dsm_ingress + + +################### +### general views # +################### +def index_page(request): + return render(request, 'index.html') + + +def faq_page(request): + return render(request, 'faq.html') + + +################ +### user views # +################ +@unauthenticated_user +def user_register_page(request): + if request.method == 'POST': + form = CreateUserForm(request.POST) + if form.is_valid(): + form.save() + username = form.cleaned_data.get('username') + messages.success(request, + _('User %s was created') % username, + extra_tags='alert-success') + return redirect('login') + else: + for val in form.errors.values(): + messages.error(request, _(val[0]), extra_tags='alert-danger') + context = { + 'username': request.POST.get('username', ''), + 'email': request.POST.get('email', ''), + 'first_name': request.POST.get('first_name', ''), + 'last_name': request.POST.get('last_name', '') + } + return render(request, 'user/register.html', context=context) + + +@unauthenticated_user +def user_login_page(request): + context = {'username': ''} + + if request.method == 'POST': + username = request.POST.get('username') + password = request.POST.get('password') + + user = authenticate(request, username=username, password=password) + + if user is not None: + login(request, user) + return redirect('index') + else: + messages.error(request, + _('Incorrect username or password'), + extra_tags='alert-danger') + context['username'] = username + + return render(request, 'user/login.html', context=context) + + +@login_required(login_url='login') +def user_logout(request): + logout(request) + return redirect('login') + + +@login_required(login_url='login') +@allowed_users(allowed_groups=['manager']) +def user_add_page(request): + context = {'user_groups': []} + + if request.method == 'POST': + form = CreateUserForm(request.POST) + + groups_names = request.POST.getlist('user_groups') + context.update({'user_groups': groups_names}) + + if form.is_valid(): + form.save() + username = form.cleaned_data.get('username') + user = controller.get_user_from_username(username) + user_groups = controller.get_groups_from_groups_names(groups_names) + controller.update_user_groups(user, user_groups) + + messages.success(request, + _('User %s was created') % username, + extra_tags='alert-success') + + else: + for val in form.errors.values(): + messages.error(request, _(val[0]), extra_tags='alert-danger') + + context.update({ + 'username': request.POST.get('username', ''), + 'email': request.POST.get('email', ''), + 'first_name': request.POST.get('first_name', ''), + 'last_name': request.POST.get('last_name', '') + }) + + context.update({'available_groups': controller.get_groups()}) + + return render(request, 'user/add.html', context=context) + + +@login_required(login_url='login') +def user_change_password_page(request): + context = {} + if request.method == 'POST': + form = PasswordChangeForm(request.user, request.POST) + if form.is_valid(): + user = form.save() + update_session_auth_hash(request, user) + messages.success( + request, + _('Your password was updated'), + extra_tags='alert-success' + ) + else: + for val in form.errors.values(): + messages.error(request, _(val[0]), extra_tags='alert-danger') + context.update({ + 'old_password': request.POST.get('old_password', ''), + 'new_password1': request.POST.get('new_password1', ''), + 'new_password2': request.POST.get('new_password2', ''), + 'form': form + }) + else: + form = PasswordChangeForm(request.user) + + return render(request, 'user/change_password.html', context=context) + + +@login_required(login_url='login') +@allowed_users(allowed_groups=['manager']) +def user_groups_edit_page(request): + user_list = controller.get_users() + available_groups = controller.get_groups() + + paginator = Paginator(user_list, 25) + page_number = request.GET.get('page') + user_obj = paginator.get_page(page_number) + + if request.method == 'POST': + ev = controller.add_event(request.user, Event.Name.CHANGE_USER_GROUPS) + + for u in user_obj: + groups_names = request.POST.getlist('%s|user_groups' % u.username) + user_groups = controller.get_groups_from_groups_names(groups_names) + controller.update_user_groups(u, user_groups) + + messages.success(request, _("Users' groups were updated"), extra_tags='alert-success') + controller.update_event(ev, {'status': Event.Status.COMPLETED}) + + return render(request, 'user/groups_edit.html', context={'user_obj': user_obj, 'available_groups': available_groups}) + + +@login_required(login_url='login') +def user_profile_page(request): + groups_names = controller.get_groups_names_from_user(request.user) + return render(request, 'user/profile.html', context={'groups': groups_names}) + + +@login_required(login_url='login') +def user_profile_edit_page(request): + if request.method == 'POST': + form = UpdateUserForm(request.POST, instance=request.user) + if form.is_valid(): + form.save() + username = form.cleaned_data.get('username') + messages.success(request, + _('User %s was updated') % username, + extra_tags='alert-success') + return redirect('user_profile_edit') + return render(request, 'user/profile_edit.html', context={}) + + +################# +# ingress views # +################# +@login_required(login_url='login') +@allowed_users(allowed_groups=['manager', 'operator_ingress']) +def ingress_package_upload_page(request): + if request.method == 'POST': + file_input = request.FILES.get('package_file') + # registra evento de envio de pacote novo + ev = controller.add_event(request.user, Event.Name.UPLOAD_PACKAGE, {'file_name': file_input.name}) + + if file_input: + fs = FileSystemStorage(location=settings.MEDIA_INGRESS_TEMP) + + # envia arquivo para diretório temporário + pkg_name = fs.save(file_input.name, file_input) + + # envia arquivo ao MinIO + try: + file_path = path.join(fs.base_location, pkg_name) + ingress_results = dsm_ingress.upload_package(file_path) + + if len(ingress_results['errors']) > 0: + messages.error(request, + _('Errors ocurred: %s') % ingress_results['errors'], + extra_tags='alert-danger') + # registra o evento como completado com falha + ev = controller.update_event(ev, {'status': Event.Status.FAILED}) + else: + for d in ingress_results['docs']: + messages.success(request, + _('Package (%(name)s, %(id)s) was added') + % {'name': d['name'], 'id': d['id']}, + extra_tags='alert-success') + # registra o evento como completado com sucesso + ev = controller.update_event(ev, {'status': Event.Status.COMPLETED}) + + # registra o pacote enviado + controller.add_ingress_package(request.user, ev.datetime, pkg_name) + except ValueError: + messages.error(request, + pkg_name + _(' does not have a valid format. Please provide a zip file.'), + extra_tags='alert-danger') + # registra o evento como completado com falha + ev = controller.update_event(ev, {'status': Event.Status.FAILED}) + + # remove arquivo de diretório temporário + fs.delete(pkg_name) + + return render(request, 'ingress/package_upload.html') + + +@login_required(login_url='login') +@allowed_users(allowed_groups=['manager', 'operator_ingress']) +def ingress_package_download_page(request): + pid = request.GET.get('pid', '') + job_id = request.GET.get('job', '') + + # Há task sendo executada: renderiza template para mostrar resultados (ou aguardar por eles) + if job_id: + job = AsyncResult(job_id) + + context = { + 'pid': pid, + 'check_status': 1, + 'data': '', + 'state': 'STARTING', + 'task_id': job_id + } + return render(request, 'ingress/package_download.html', context) + + # Inicializa task para o PID informado e redireciona para a própria página aguardando resultado + elif pid: + job = task_get_package_uri_by_pid.delay(pid) + return HttpResponseRedirect(reverse('ingress_package_download') + '?job=' + job.id + '&pid=' + pid) + + # Abre template pela primeira vez para digitar PID + return render(request, 'ingress/package_download.html') + + +@login_required(login_url='login') +@allowed_users(allowed_groups=['manager', 'operator_ingress']) +def ingress_package_list_page(request): + request_scope = request.GET.get('scope', '') + deposited_package_list = controller.get_ingress_packages_from_user_and_scope(request.user, request_scope) + + paginator = Paginator(deposited_package_list, 25) + page_number = request.GET.get('page') + deposited_package_obj = paginator.get_page(page_number) + + return render(request, 'ingress/package_list.html', context={'deposited_package_obj': deposited_package_obj, 'scope': request_scope}) + + +@login_required(login_url='login') +@allowed_users(allowed_groups=['manager', 'operator_ingress']) +def ingress_articles_files_page(request): + article_files_list = dsm_ingress._docs_manager.get_articles_files() + + paginator = Paginator(article_files_list, 25) + page_number = request.GET.get('page') + article_files_obj = paginator.get_page(page_number) + + return render(request, 'ingress/article_files_list.html', context={'article_files_obj': article_files_obj}) + + +################# +# journal views # +################# +@login_required(login_url='login') +@allowed_users(allowed_groups=['manager', 'operator_ingress']) +def journal_list_page(request): + journal_list = dsm_ingress._journals_manager.get_journals() + + paginator = Paginator(journal_list, 25) + page_number = request.GET.get('page') + journal_obj = paginator.get_page(page_number) + + return render(request, 'journal/journal_list.html', context={'journal_obj': journal_obj}) + + +################## +# tracking views # +################## +@login_required(login_url='login') +def event_list_page(request): + request_scope = request.GET.get('scope', '') + event_list = controller.get_events_from_user_and_scope(request.user, request_scope) + + paginator = Paginator(event_list, 25) + page_number = request.GET.get('page') + event_obj = paginator.get_page(page_number) + + return render(request, 'tracking/event_list.html', context={'event_obj': event_obj, 'scope': request_scope}) + + +@login_required(login_url='login') +@allowed_users(allowed_groups=['manager', 'operator_ingress', 'operator_migration', 'quality_analyst']) +def task_update_status(request): + """Obtém status (STARTING, FAILURY, PROGRESS, SUCCESS ou UNDEFINED) de task executada.""" + try: + task_id = request.GET['task_id'] + task = AsyncResult(task_id) + result = task.result + status = task.status + except: + result = 'UNDEFINED' + status = 'UNDEFINED' + + json_data = { + 'status': status, + 'state': 'PROGRESS', + 'data': result, + } + + return JsonResponse(json_data) From fad7e2d749bc81bbcd95501325cbfe9928c457b5 Mon Sep 17 00:00:00 2001 From: Rafael J P D Date: Mon, 1 Nov 2021 21:56:49 -0300 Subject: [PATCH 10/10] atualiza readme --- README.md | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f25f437..d9eaf4b 100644 --- a/README.md +++ b/README.md @@ -31,14 +31,14 @@ pip install . _Set the environment variables_ ```shell -export $(cat dev.ini | xargs) +export $(cat .env.dev | xargs) ``` _Create a PostgreSQL database named "spf"_ ```shell # Through a Docker container with a PostgreSQL database -docker exec --user postgres -it scielo-postgres-1 psql -c 'create database spf;' +docker exec --user postgres -it scl_postgres_1 psql -c 'create database spf;' # Or through psql psql --user postgres; @@ -108,22 +108,29 @@ python ../manage.py compilemessages ```shell # Ensure you are in the project root directory. Executing `ls .` will list the following files/directories: -dev.env +app docker-compose.yml -docker-entrypoint.sh -Dockerfile LICENSE -prod.env +nginx README.md -requirements.txt -setup.py -spf -# Build image -docker-compose -f docker-compose.yml build +# Create a .env.prod file (and add to it the necessary environment variables) +touch .env.prod -# Create and start a container with the image built -docker-compose up +# Build image and start the services +docker-compose -f docker-compose.yml up -d --build + +# Migrate data +docker-compose -f docker-compose.yml exec web python manage.py migrate --noinput + +# Collect static files +docker-compose -f docker-compose.yml exec web python manage.py collectstatic --no-input --clear + +# Load default groups +docker-compose -f docker-compose.yml exec web python manage.py loaddata group + +# Load example users +docker-compose -f docker-compose.yml exec web python manage.py loaddata user # Make sure PostgreSQL and MongoDB databases are in the same network as the spf application ```