diff --git a/Dockerfile b/Dockerfile index 59511c03d6a1e726c11f9642fe87f705c8f04ce7..e9042052f00a4aa4a04a95a16125d61cc4e6b775 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM python:3.6-slim-stretch -ENV FLASK_APP=opaque.py +ENV FLASK_APP=nopaque.py RUN apt-get update \ @@ -12,23 +12,23 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* -RUN groupadd --gid 1000 --system opaque \ - && useradd --create-home --gid opaque --no-log-init --system --uid 1000 opaque -USER opaque -WORKDIR /home/opaque +RUN groupadd --gid 1000 --system nopaque \ + && useradd --create-home --gid nopaque --no-log-init --system --uid 1000 nopaque +USER nopaque +WORKDIR /home/nopaque COPY ["app", "app"] COPY ["migrations", "migrations"] COPY ["tests", "tests"] -COPY ["config.py", "opaque.py", "requirements.txt", "./"] +COPY ["config.py", "nopaque.py", "requirements.txt", "./"] RUN python -m venv venv \ && venv/bin/pip install --requirement requirements.txt \ && mkdir logs EXPOSE 5000 -VOLUME ["/home/opaque/logs", "/home/opaque/migrations"] +VOLUME ["/home/nopaque/logs", "/home/nopaque/migrations"] COPY ["docker-entrypoint.sh", "/usr/local/bin/"] diff --git a/README.md b/README.md index dd8725789c48166970d25f8ecae645d9281c7462..6c25284c400bb2c2303e4793fd9b1ae53650bf79 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ echo "MAIL_SERVER=smtp.example.com" >> .env echo "MAIL_PORT=587" >> .env echo "MAIL_USE_TLS=true" >> .env # A user registering with this email address will automatically promoted as an admin. -echo "OPAQUE_ADMIN=admin.opaque@example.com" >> .env +echo "NOPAQUE_ADMIN=admin.opaque@example.com" >> .env # Absolut path to an existing directory to save all opaque files. echo "OPAQUE_STORAGE=/home/opaque/mnt/opaque" >> .env ``` diff --git a/app/auth/views.py b/app/auth/views.py index 74afc4907e1b23ede76caf3052a591291cec1d18..22a1195414b5485cec94e062fb086d9e8e912d3b 100644 --- a/app/auth/views.py +++ b/app/auth/views.py @@ -48,7 +48,7 @@ def register(): username=registration_form.username.data) db.session.add(user) db.session.commit() - dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'], + dir = os.path.join(current_app.config['NOPAQUE_STORAGE'], str(user.id)) try: os.makedirs(dir) diff --git a/app/corpora/views.py b/app/corpora/views.py index 5f07173bd787183db4fb312e5cfe1865b1d20ae0..f2d6f83a7d81fa1c38f4a3173b70154d9e9dc4a4 100644 --- a/app/corpora/views.py +++ b/app/corpora/views.py @@ -23,7 +23,7 @@ def add_corpus(): status='unprepared', title=add_corpus_form.title.data) db.session.add(corpus) db.session.commit() - dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'], + dir = os.path.join(current_app.config['NOPAQUE_STORAGE'], str(corpus.user_id), 'corpora', str(corpus.id)) try: os.makedirs(dir) @@ -95,7 +95,7 @@ def add_corpus_file(corpus_id): corpus_id=corpus_id)) # Save the file dir = os.path.join(str(corpus.user_id), 'corpora', str(corpus.id)) - file.save(os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'], + file.save(os.path.join(current_app.config['NOPAQUE_STORAGE'], dir, filename)) corpus_file = CorpusFile(author=add_corpus_file_form.author.data, corpus=corpus, dir=dir, filename=filename, @@ -139,7 +139,7 @@ def download_corpus_file(corpus_id, corpus_file_id): if not (corpus_file.corpus.creator == current_user or current_user.is_administrator()): abort(403) - dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'], + dir = os.path.join(current_app.config['NOPAQUE_STORAGE'], corpus_file.dir) return send_from_directory(as_attachment=True, directory=dir, filename=corpus_file.filename) diff --git a/app/jobs/views.py b/app/jobs/views.py index 08fd825ccb96638808a73d8702e95c643240ba70..a5bbe7231d7383aea9d9d5805383fcaf3b8855be 100644 --- a/app/jobs/views.py +++ b/app/jobs/views.py @@ -39,7 +39,7 @@ def download_job_input(job_id, job_input_id): if not (job_input.job.creator == current_user or current_user.is_administrator()): abort(403) - dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'], + dir = os.path.join(current_app.config['NOPAQUE_STORAGE'], job_input.dir) return send_from_directory(as_attachment=True, directory=dir, filename=job_input.filename) @@ -54,7 +54,7 @@ def download_job_result(job_id, job_result_id): if not (job_result.job.creator == current_user or current_user.is_administrator()): abort(403) - dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'], + dir = os.path.join(current_app.config['NOPAQUE_STORAGE'], job_result.dir) return send_from_directory(as_attachment=True, directory=dir, filename=job_result.filename) diff --git a/app/main/views.py b/app/main/views.py index fe8ec583f154c1c44421791eebd36b8b210795da..5f20d853588505586462bab3590f1473f8aa473b 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -5,7 +5,7 @@ from . import main @main.route('/') def index(): - return render_template('main/index.html.j2', title='Opaque') + return render_template('main/index.html.j2', title='nopaque') @main.route('/dashboard') diff --git a/app/models.py b/app/models.py index 87cd38dfebf8a76e70c302777e7634c6f62beb95..32f0d109fbe633fe89855791cd52eafe5476ef8e 100644 --- a/app/models.py +++ b/app/models.py @@ -128,7 +128,7 @@ class User(UserMixin, db.Model): def __init__(self, **kwargs): super(User, self).__init__(**kwargs) if self.role is None: - if self.email == current_app.config['OPAQUE_ADMIN']: + if self.email == current_app.config['NOPAQUE_ADMIN']: self.role = Role.query.filter_by(name='Administrator').first() if self.role is None: self.role = Role.query.filter_by(default=True).first() @@ -213,7 +213,7 @@ class User(UserMixin, db.Model): job.delete() for corpus in self.corpora: corpus.delete() - path = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'], + path = os.path.join(current_app.config['NOPAQUE_STORAGE'], str(self.id)) try: shutil.rmtree(path) @@ -333,7 +333,7 @@ class Job(db.Model): while self.status != 'deleted': sleep(1) db.session.refresh(self) - path = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'], + path = os.path.join(current_app.config['NOPAQUE_STORAGE'], str(self.user_id), 'jobs', str(self.id)) try: shutil.rmtree(path) @@ -377,7 +377,7 @@ class CorpusFile(db.Model): corpus_id = db.Column(db.Integer, db.ForeignKey('corpora.id')) def delete(self): - path = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'], + path = os.path.join(current_app.config['NOPAQUE_STORAGE'], self.dir, self.filename) try: os.remove(path) @@ -390,7 +390,7 @@ class CorpusFile(db.Model): db.session.commit() def insert_metadata(self): - file = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'], + file = os.path.join(current_app.config['NOPAQUE_STORAGE'], self.dir, self.filename) element_tree = ET.parse(file) text_node = element_tree.find('text') @@ -437,7 +437,7 @@ class Corpus(db.Model): def delete(self): for corpus_file in self.files: corpus_file.delete() - path = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'], + path = os.path.join(current_app.config['NOPAQUE_STORAGE'], str(self.user_id), 'corpora', str(self.id)) try: shutil.rmtree(path) diff --git a/app/services/views.py b/app/services/views.py index 6cbf9d3910b5001a2a3c1b479c9e4398428212fe..787ebac0a4c3f7dca3e964bed8d5e2f1c34a41d7 100644 --- a/app/services/views.py +++ b/app/services/views.py @@ -45,7 +45,7 @@ def service(service): db.session.commit() relative_dir = os.path.join(str(job.user_id), 'jobs', str(job.id)) absolut_dir = os.path.join( - current_app.config['OPAQUE_STORAGE_DIRECTORY'], relative_dir) + current_app.config['NOPAQUE_STORAGE'], relative_dir) try: os.makedirs(absolut_dir) except OSError: diff --git a/app/static/css/opaque.css b/app/static/css/nopaque.css similarity index 100% rename from app/static/css/opaque.css rename to app/static/css/nopaque.css diff --git a/app/templates/base.html.j2 b/app/templates/base.html.j2 index a6d4c55958c04e02ccfa08a06f6a90da4ce32dd1..04d92c74b1b7c9a57c928e43d69a8d37103c4cb6 100644 --- a/app/templates/base.html.j2 +++ b/app/templates/base.html.j2 @@ -3,14 +3,14 @@ <head> <meta charset="UTF-8"> {% if title %} - <title>Opaque – {{ title }}</title> + <title>nopaque – {{ title }}</title> {% else %} - <title>Opaque</title> + <title>nopaque</title> {% endif %} <link href="{{ url_for('static', filename='images/favicon.png') }}" rel="icon" type="image/png"> <link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='fonts/material-icons/material-icons.css') }}"> <link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/materialize.min.css') }}" media="screen,projection"/> - <link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/opaque.css') }}" media="screen,projection"/> + <link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/nopaque.css') }}" media="screen,projection"/> <script src="{{ url_for('static', filename='js/add_job.js') }}"></script> <script src="{{ url_for('static', filename='js/jsonpatch.min.js') }}"></script> <script src="{{ url_for('static', filename='js/socket.io.js') }}"></script> @@ -111,7 +111,7 @@ <div class="navbar-fixed"> <nav> <div class="nav-wrapper"> - <a href="{{ url_for('main.index') }}" class="brand-logo center"><i class="material-icons">opacity</i>Opaque</a> + <a href="{{ url_for('main.index') }}" class="brand-logo center"><i class="material-icons">opacity</i>nopaque</a> <a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a> <ul class="right hide-on-med-and-down"> <li><a id="nav-notifications" class="dropdown-trigger no-autoinit" href="#!" data-target="nav-notifications-dropdown"><i class="material-icons">notifications</i></a></li> @@ -130,7 +130,7 @@ </div> <ul id="slide-out" class="sidenav sidenav-fixed"> - <li><a href="{{ url_for('main.index') }}"><i class="material-icons">opacity</i>Opaque</a></li> + <li><a href="{{ url_for('main.index') }}"><i class="material-icons">opacity</i>nopaque</a></li> <li><a href="#"><i class="material-icons">linear_scale</i>Workflow</a></li> <li><a href="{{ url_for('main.dashboard') }}"><i class="material-icons">dashboard</i>Dashboard</a></li> <li><div class="divider"></div></li> diff --git a/app/templates/main/index.html.j2 b/app/templates/main/index.html.j2 index 2abd190cca4491f7abad3974536497fac1979f61..b303666f43b6459f4b210831d014bb9917b41594 100644 --- a/app/templates/main/index.html.j2 +++ b/app/templates/main/index.html.j2 @@ -2,7 +2,7 @@ {% block page_content %} <div class="col s12 m4"> - <h3>Opaque?</h3> + <h3>nopaque?</h3> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,</p> </div> diff --git a/config.py b/config.py index 737d56681f9dc7a8884b14715c81cdcfe94fd23f..9212705d9e01cbb8e472e9706c57b8f34c38305a 100644 --- a/config.py +++ b/config.py @@ -18,8 +18,8 @@ class Config: SQLALCHEMY_TRACK_MODIFICATIONS = False ''' ### Opaque ### ''' - OPAQUE_ADMIN = os.environ.get('OPAQUE_ADMIN') - OPAQUE_STORAGE_DIRECTORY = '/mnt/opaque' + NOPAQUE_ADMIN = os.environ.get('NOPAQUE_ADMIN') + NOPAQUE_STORAGE = '/mnt/opaque' @staticmethod def init_app(app): diff --git a/docker-compose.yml b/docker-compose.yml index 8993aed7e7670cc2c042cd5ab205a59fe91b27a2..22cccd880807762e0dc4a055e16c688a48a0db10 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,14 +13,14 @@ services: - 5000:5000 volumes: - /mnt/opaque:/mnt/opaque - - ./app:/home/opaque/app - - ./logs:/home/opaque/logs - - ./migrations:/home/opaque/migrations - - ./tests:/home/opaque/tests - - ./config.py:/home/opaque/config.py + - ./app:/home/nopaque/app + - ./logs:/home/nopaque/logs + - ./migrations:/home/nopaque/migrations + - ./tests:/home/nopaque/tests + - ./config.py:/home/nopaque/config.py - ./docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh - - ./opaque.py:/home/opaque/opaque.py - - ./requirements.txt:/home/opaque/requirements.txt + - ./nopaque.py:/home/nopaque/nopaque.py + - ./requirements.txt:/home/nopaque/requirements.txt daemon: depends_on: - db @@ -30,12 +30,12 @@ services: image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque_daemon:latest volumes: - /mnt/opaque:/mnt/opaque - - ./logs:/home/opaque_daemon/logs + - ./logs:/home/nopaqued/logs - ../opaque_daemon/docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh - - ../opaque_daemon/opaque_daemon.py:/home/opaque_daemon/opaque_daemon.py - - ../opaque_daemon/merge_corpus_files.py:/home/opaque_daemon/merge_corpus_files.py - - ../opaque_daemon/requirements.txt:/home/opaque_daemon/requirements.txt - - $HOME/.docker/config.json:/home/opaque_daemon/.docker/config.json + - ../opaque_daemon/nopaqued.py:/home/nopaqued/opaque_daemon.py + - ../opaque_daemon/merge_corpus_files.py:/home/nopaqued/merge_corpus_files.py + - ../opaque_daemon/requirements.txt:/home/nopaqued/requirements.txt + - $HOME/.docker/config.json:/home/nopaqued/.docker/config.json db: env_file: db.env image: postgres:11 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 3abf7198da41737837fa7127ffb2086d3022bfdb..dd7c6d6ffa2d77c999b8876fb7a533ac74227e0a 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -7,7 +7,7 @@ wait-for-it redis:6379 --strict --timeout=0 if [ $# -eq 0 ] then - venv/bin/python -u opaque.py + venv/bin/python -u nopaque.py elif [ $1 == "flask" ] then echo "$@" diff --git a/opaque.py b/nopaque.py similarity index 100% rename from opaque.py rename to nopaque.py diff --git a/web.env.tpl b/web.env.tpl index 274698b77e8c4fadccff3631e2cb44ae08bc0088..09209c7e6dd9efd12f1b09b04595e7643fa0a22a 100644 --- a/web.env.tpl +++ b/web.env.tpl @@ -10,5 +10,5 @@ MAIL_USERNAME=username@example.com MAIL_PASSWORD=password MAIL_DEFAULT_SENDER=username@example.com -### Opaque ### -OPAQUE_ADMIN=admin.opaque@example.com +### nopaque ### +NOPAQUE_ADMIN=admin.opaque@example.com