Skip to content

Commit

Permalink
Merge pull request #29 from rafaelpezzuto/fix-prod-server
Browse files Browse the repository at this point in the history
Faz melhorias gerais
  • Loading branch information
rafaelpezzuto authored Nov 2, 2021
2 parents 3debd2a + b749c03 commit 13d59ce
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 214 deletions.
34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ Be sure that you have the necessary operational system dependencies:

```shell
gettext
python 3.9
python 3
```

_Create a virtual environment and install the application dependencies_

```shell
# Create a virtual environment
virtualenv -p python3.9 .venv
virtualenv -p python3 .venv

# Access the virtual environment
source .venv/bin/activate

# Access the folder app
cd app

# Install dependencies
pip install -r requirements.txt

Expand All @@ -31,6 +34,10 @@ pip install .
_Set the environment variables_

```shell
# Create a dotenv file (and add to it the necessary environment variables - see List of environmental variables)
touch .env.dev

# Export its contents to the system enviroment
export $(cat .env.dev | xargs)
```

Expand All @@ -55,27 +62,27 @@ _Prepare and run the application_

```shell
# Make migrations related to the database
python spf/manage.py makemigrations
python manage.py makemigrations

# Migrate database (this operation will create all the necessary tables)
python spf/manage.py migrate
python manage.py migrate

# Create the superuser (take note of the credentials)
python spf/manage.py createsuperuser
python manage.py createsuperuser
```

_Add default groups to the application database_

```shell
# Add default groups to the application database
python spf/manage.py loaddata group
python manage.py loaddata group
```

_Add example users to the application database (only in development environments)_

```shell
# Add example users to the application database
python spf/manage.py loaddata user
python manage.py loaddata user
```

_Run the application_
Expand All @@ -85,7 +92,7 @@ _Run the application_
celery -A spf worker -l INFO

# Start the application
python spf/manage.py runserver
python manage.py runserver
```

_How to translate the interface content to other languages_
Expand Down Expand Up @@ -114,7 +121,7 @@ LICENSE
nginx
README.md

# Create a .env.prod file (and add to it the necessary environment variables)
# Create a dotenv file (and add to it the necessary environment variables - see List of environmental variables)
touch .env.prod

# Build image and start the services
Expand All @@ -141,18 +148,9 @@ Variable | Example value | Description
---------|---------------|------------
CELERY_BROKER_URL | `pyamqp://user:pass@host:port` | RabbitMQ address
DATABASE_CONNECT_URL | `mongodb://user:pass@host:port/opac` | OPAC/Kernel database (MongoDB) string connection
DJANGO_ADMIN_TRANSLATE | `1` | Django flag to run `django-admin compile_messages`
DJANGO_ALLOWED_HOSTS | `localhost;127.0.0.1;[::1]` |
DJANGO_COLLECTSTATIC | `1` |Django flag to run `manage.py collecstatic`
DJANGO_CREATE_SUPERUSER | `1` | Django flag to run `manage.py createsuperuser`
DJANGO_DEBUG | `1` | Django flag to see DEBUG messages
DJANGO_MANAGE_LOAD_GROUP | `1` | Django flag to run `manage.py loaddata group`
DJANGO_MANAGE_LOAD_USER | `1` | Django flag to run `manage.py loaddata user`
DJANGO_MANAGE_MIGRATE | `1` | Django flag to run `managep.py migrate`
DJANGO_SECRET_KEY | | Django secret key
DJANGO_SUPERUSER_EMAIL | | superuser email
DJANGO_SUPERUSER_PASSWORD | | superuser password
DJANGO_SUPERUSER_USERNAME | | superuser username
MINIO_ACCESS_KEY | | MinIO username
MINIO_HOST | `host:port` | MinIO host address
MINIO_SCIELO_COLLECTION | | MinIO collection name
Expand Down
6 changes: 3 additions & 3 deletions app/core/templates/ingress/package_download.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ <h2 class="h4">{% trans 'Results for document' %} <strong>{{ pid }}</strong></h2
<table class="table table-bordered" id="table">
<thead>
<tr>
<th>{% trans 'Package' %}</th>
<th>{% trans 'Version' %}</th>
<th>{% trans 'Package name' %}</th>
<th>{% trans 'Creation date' %}</th>
<th>{% trans 'Update date' %}</th>
</tr>
</thead>
<tbody id="resultSearchPackagesTableBody">
Expand Down Expand Up @@ -87,4 +87,4 @@ <h2 class="h4">{% trans 'Results for document' %} <strong>{{ pid }}</strong></h2
ingressPackageDownloadToggleSpinner();
}
</script>
{% endblock %}
{% endblock %}
19 changes: 1 addition & 18 deletions app/setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/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',
Expand All @@ -30,9 +26,7 @@
version="0.1",
author="SciELO",
author_email="[email protected]",
description="",
long_description=README,
long_description_content_type="text/markdown",
description="This is the SciELO Upload Framework",
license="2-clause BSD",
packages=setuptools.find_packages(
exclude=["*.tests", "*.tests.*", "tests.*", "tests"]
Expand All @@ -44,15 +38,4 @@
],
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",
],
)
2 changes: 1 addition & 1 deletion app/spf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

DEBUG = int(os.environ.get('DJANGO_DEBUG', 0))

ALLOWED_HOSTS = os.environ.get('DJANGO_ALLOWED_HOSTS').split(' ')
ALLOWED_HOSTS = os.environ.get('DJANGO_ALLOWED_HOSTS').split(';')

INSTALLED_APPS = [
'django.contrib.admin',
Expand Down
35 changes: 19 additions & 16 deletions app/static/js/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function createMessage(msg){
function createMessage(msg, alert_class){
divAlert = document.createElement('div');
divAlert.classList.add('alert', 'alert-danger', 'alert-dismissible', 'fade', 'show', 'is-no-rounded', 'm-0', 'p-2');
divAlert.classList.add('alert', alert_class, 'alert-dismissible', 'fade', 'show', 'is-no-rounded', 'm-0', 'p-2');
divAlert.setAttribute('role', 'alert');

divContainer = document.createElement('div');
Expand Down Expand Up @@ -34,31 +34,34 @@ function ingressPackageDownloadToggleSpinner(){
function ingressPackageDownloadCreateTable(data){
tableBody = document.getElementById('resultSearchPackagesTableBody')

for (k in data['doc_pkg']){
els = data['doc_pkg'][k];
counter = 1
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);
tdUri.innerHTML = counter;

aPkgName = document.createElement('a')
aPkgName.text = els['name'];
aPkgName.href = els['uri'];
aPkgName.classList.add('link');

tdPkgName = row.insertCell(-1);
tdPkgName.appendChild(aPkgName);

tdCreated = row.insertCell(-1);
tdCreated.innerHTML = els['created'];
tdCreated = row.insertCell(-1)
tdCreated.innerHTML = new Date(els['created']);

tdUpdated = row.insertCell(-1);
tdUpdated.innerHTML = els['updated'];
counter += 1;
}

if (data['doc_pkg'].length > 0) {
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]);
element_message = createMessage(data['errors'][k], 'alert-danger');
divBaseMessages.append(element_message);
}
}
Expand Down
68 changes: 0 additions & 68 deletions spf/core/static/js/main.js

This file was deleted.

90 changes: 0 additions & 90 deletions spf/core/templates/ingress/package_download.html

This file was deleted.

0 comments on commit 13d59ce

Please sign in to comment.