diff --git a/web/app/__init__.py b/web/app/__init__.py index f0e9a4ce..57d5d73c 100644 --- a/web/app/__init__.py +++ b/web/app/__init__.py @@ -59,7 +59,4 @@ def create_app(config_name): from .services import services as services_blueprint app.register_blueprint(services_blueprint, url_prefix='/services') - from .results import results as results_blueprint - app.register_blueprint(results_blueprint, url_prefix='/results') - return app diff --git a/web/app/models.py b/web/app/models.py index 24fd7b3a..d377272c 100644 --- a/web/app/models.py +++ b/web/app/models.py @@ -133,8 +133,6 @@ class User(UserMixin, db.Model): cascade='save-update, merge, delete') jobs = db.relationship('Job', backref='creator', lazy='dynamic', cascade='save-update, merge, delete') - results = db.relationship('Result', backref='creator', lazy='dynamic', - cascade='save-update, merge, delete') query_results = db.relationship('QueryResult', backref='creator', cascade='save-update, merge, delete', @@ -660,59 +658,6 @@ class QueryResult(db.Model): return ''.format(self.title) -class Result(db.Model): - ''' - Class to define a result set of one query. - ''' - __tablename__ = 'results' - id = db.Column(db.Integer, primary_key=True) - # Foreign keys - user_id = db.Column(db.Integer, db.ForeignKey('users.id')) - # Relationships' - corpus_metadata = db.Column(db.JSON()) - file = db.relationship('ResultFile', backref='result', lazy='dynamic', - cascade='save-update, merge, delete') - - def delete(self): - result_file_path = os.path.join(current_app.config['NOPAQUE_STORAGE'], - self.file[0].dir) - try: - os.remove(result_file_path) - except OSError: - pass - db.session.delete(self) - - def __repr__(self): - ''' - String representation of the Result. For human readability. - ''' - return ''.format(result_id=self.id) - - -class ResultFile(db.Model): - ''' - Class to define a ResultFile - ''' - __tablename__ = 'result_files' - # Primary key - id = db.Column(db.Integer, primary_key=True) - # Foreign keys - result_id = db.Column(db.Integer, db.ForeignKey('results.id')) - # Fields - filename = db.Column(db.String(255)) - dir = db.Column(db.String(255)) - - def delete(self): - db.session.delete(self) - db.session.commit() - - def __repr__(self): - ''' - String representation of the ResultFile. For human readability. - ''' - return ''.format(result_file_name=self.filename) # noqa - - ''' ' Flask-Login is told to use the application’s custom anonymous user by setting ' its class in the login_manager.anonymous_user attribute. diff --git a/web/app/results/__init__.py b/web/app/results/__init__.py deleted file mode 100644 index 2f1f59a7..00000000 --- a/web/app/results/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from flask import Blueprint - - -results = Blueprint('results', __name__) -from . import views # noqa \ No newline at end of file diff --git a/web/app/results/forms.py b/web/app/results/forms.py deleted file mode 100644 index 13533ca6..00000000 --- a/web/app/results/forms.py +++ /dev/null @@ -1,18 +0,0 @@ -from flask_wtf import FlaskForm -from werkzeug.utils import secure_filename -from wtforms import FileField, SubmitField, ValidationError -from wtforms.validators import DataRequired - - -class ImportResultsForm(FlaskForm): - ''' - Form used to import one result json file. - ''' - file = FileField('File', validators=[DataRequired()]) - submit = SubmitField() - - def validate_file(self, field): - if not field.data.filename.lower().endswith('.json'): - raise ValidationError('File does not have an approved extension: ' - '.json') - field.data.filename = secure_filename(field.data.filename) diff --git a/web/app/results/tasks.py b/web/app/results/tasks.py deleted file mode 100644 index d139501f..00000000 --- a/web/app/results/tasks.py +++ /dev/null @@ -1,13 +0,0 @@ -from .. import db -from ..decorators import background -from ..models import Result - - -@background -def delete_result(result_id, *args, **kwargs): - with kwargs['app'].app_context(): - result = Result.query.get(result_id) - if result is None: - raise Exception('Result {} not found'.format(result_id)) - result.delete() # cascades down and also deletes ResultFile - db.session.commit() diff --git a/web/app/results/views.py b/web/app/results/views.py deleted file mode 100644 index 733ac962..00000000 --- a/web/app/results/views.py +++ /dev/null @@ -1,186 +0,0 @@ -from . import results -from . import tasks -from .. import db -from ..corpora.forms import DisplayOptionsForm, InspectDisplayOptionsForm -from ..models import Result, ResultFile, User -from .forms import ImportResultsForm -from datetime import datetime -from flask import (abort, render_template, current_app, request, redirect, - flash, url_for, make_response, send_from_directory) -from flask_login import current_user, login_required -import json -import os -from .. import logger -from jsonschema import validate - - -@results.route('/import', methods=['GET', 'POST']) -@login_required -def result_import(): - ''' - View to import one json result file. Uses the ImportReultFileForm. - ''' - import_results_form = ImportResultsForm(prefix='add-result-file-form') - if import_results_form.is_submitted(): - if not import_results_form.validate(): - return make_response(import_results_form.errors, 400) - # Save the file - # result creation only happens on file save to avoid creating a result - # object in the db everytime by just visiting the import_results page - result = Result(user_id=current_user.id) - db.session.add(result) - db.session.commit() - if not (result.creator == current_user - or current_user.is_administrator()): - abort(403) - # create paths to save the uploaded json file - dir = os.path.join(str(result.user_id), - 'results', - 'corpus_analysis_results', - str(result.id)) - abs_dir = os.path.join(current_app.config['NOPAQUE_STORAGE'], dir) - abs_file_path = os.path.join(abs_dir, - import_results_form.file.data.filename) - os.makedirs(abs_dir) - # save the json file - import_results_form.file.data.save(abs_file_path) - # Create ResultFile db entry - result_file = ResultFile(result_id=result.id, - dir=dir, - filename=import_results_form.file.data.filename) # noqa - db.session.add(result_file) - db.session.commit() - # reads uploaded json file - with open(abs_file_path, 'r') as f: - corpus_metadata = json.load(f) - try: - # open json schema to validate against it - with open('app/static/json_schema/nopaque_cqi_py_results_schema.json', # noqa - 'r') as s: - schema = json.load(s) - # validate if imported json is actually a json result file - validate(instance=corpus_metadata, schema=schema) - # if validated continue - # delete matches and cpos_lookup from read json file - del corpus_metadata['matches'] - del corpus_metadata['cpos_lookup'] - # save metadate directly as json into one field - result.corpus_metadata = corpus_metadata - flash('Result file added!', 'result') - db.session.commit() - return make_response( - {'redirect_url': url_for('results.results_overview')}, - 201) - except Exception as e: - # this runs if validation fails - flash('Uploaded file was not a valid result JSON!', 'result') - # deletes before created Result and ResultFile db entries - tasks.delete_result(result.id) - return make_response( - {'redirect_url': url_for('results.result_import')}, - 201) - return render_template('results/result_import.html.j2', - import_results_form=import_results_form, - title='Add corpus file') - - -@results.route('/') -@login_required -def results_overview(): - ''' - Shows an overview of imported results. - ''' - # get all results of current user - results = User.query.get(current_user.id).results - - def __p_time(time_str): - # helper to convert the datetime into a nice readable string - return datetime.strptime(time_str, '%Y-%m-%dT%H:%M:%S.%f') - - # convert results into a list of dicts to add the measier to list.js in - # the template - results = [dict(query=r.corpus_metadata['query'], - match_count=r.corpus_metadata['match_count'], - corpus_name=r.corpus_metadata['corpus_name'], - corpus_creation_date=__p_time(r.corpus_metadata['corpus_creation_date']), # noqa - corpus_analysis_date=__p_time(r.corpus_metadata['corpus_analysis_date']), # noqa - corpus_type=r.corpus_metadata['corpus_type'], - file_id=r.file[0].id, - id=r.id) - for r in results] - return render_template('results/results.html.j2', - title='Imported Results', - # table=table, - results=results) - - -@results.route('//details') -@login_required -def result_details(result_id): - ''' - View to show metadate and details about on imported result file. - ''' - result = Result.query.get_or_404(result_id) - if not (result.creator == current_user or current_user.is_administrator()): - abort(403) - return render_template('results/result_details.html.j2', - result=result, - title='Result Details') - - -@results.route('//inspect') -@login_required -def result_inspect(result_id): - ''' - View to inspect one imported result file in a corpus analysis like interface - ''' - display_options_form = DisplayOptionsForm( - prefix='display-options-form', - result_context=request.args.get('context', 20), - results_per_page=request.args.get('results_per_page', 30)) - inspect_display_options_form = InspectDisplayOptionsForm( - prefix='inspect-display-options-form') - result = Result.query.get_or_404(result_id) - result_file_path = os.path.join(current_app.config['NOPAQUE_STORAGE'], - result.file[0].dir, - result.file[0].filename) - with open(result_file_path, 'r') as result_json: - result_json = json.load(result_json) - if not (result.creator == current_user or current_user.is_administrator()): - abort(403) - return render_template('results/result_inspect.html.j2', - display_options_form=display_options_form, - inspect_display_options_form=inspect_display_options_form, - result=result, - result_json=result_json, - title='Result Insepct') - - -@results.route('//delete') -@login_required -def result_delete(result_id): - result = Result.query.get_or_404(result_id) - if not result.id == result_id: - abort(404) - if not (result.creator == current_user - or current_user.is_administrator()): - abort(403) - tasks.delete_result(result_id) - flash('Result deleted!') - return redirect(url_for('results.results_overview')) - - -@results.route('//file//download') -@login_required -def result_download(result_id, result_file_id): - result_file = ResultFile.query.get_or_404(result_file_id) - if not result_file.result_id == result_id: - abort(404) - if not (result_file.result.creator == current_user - or current_user.is_administrator()): - abort(403) - dir = os.path.join(current_app.config['NOPAQUE_STORAGE'], - result_file.dir) - return send_from_directory(as_attachment=True, - directory=dir, - filename=result_file.filename) diff --git a/web/app/static/js/nopaque.lists.js b/web/app/static/js/nopaque.lists.js index fdad5178..7288e8b1 100644 --- a/web/app/static/js/nopaque.lists.js +++ b/web/app/static/js/nopaque.lists.js @@ -1,6 +1,6 @@ class RessourceList extends List { constructor(idOrElement, subscriberList, type, options={}) { - if (!["Corpus", "CorpusFile", "Job", "JobInput", "QueryResult", "User", "result"].includes(type)) { + if (!["Corpus", "CorpusFile", "Job", "JobInput", "QueryResult", "User"].includes(type)) { console.error("Unknown Type!"); return; } @@ -124,16 +124,6 @@ RessourceList.dataMapper = { link: `/query_results/${query_result.id}`, query: query_result.query_metadata.query, title: query_result.title}), - result: result => ({query: result.query, - match_count: result.match_count, - corpus_name: result.corpus_name, - corpus_creation_date: result.corpus_creation_date, - corpus_analysis_date: result.corpus_analysis_date, - corpus_type : result.corpus_type, - "details-link": `${result.id}/details`, - "inspect-link": `${result.id}/inspect`, - "download-link": `${result.id}/file/${result.file_id}/download`, - "delete-modal": `delete-result-${result.id}-modal`}), // Mapping for user entities shown in admin table User: user => ({username: user.username, email: user.email, @@ -277,56 +267,6 @@ RessourceList.options = { {data: ["id"]}, {name: "inspect-link", attr: "href"}, {name: "link", attr: "href"}]}, - // Result (imported from corpus analysis) entity blueprint setting html - // strucuture per entity per row - // Link classes have to correspond with Links defined in the Mapping process - result: {item: ` - - - - - - - - - info_outline - - - search - - - file_download - - - delete - - - `, - // Result Value Names per column. Have to correspond with keys from the - // Mapping step above. - valueNames: ["query", - "match_count", - "corpus_name", - "corpus_creation_date", - "corpus_analysis_date", - "corpus_type", - {name: "details-link", attr: "href"}, - {name: "inspect-link", attr: "href"}, - {name: "download-link", attr: "href"}, - {name: "delete-modal", attr: "data-target"}] - }, // User entity blueprint setting html strucuture per entity per row // Link classes have to correspond with Links defined in the Mapping process User: {item: ` diff --git a/web/app/templates/main/dashboard.html.j2 b/web/app/templates/main/dashboard.html.j2 index 420ed561..fa45862c 100644 --- a/web/app/templates/main/dashboard.html.j2 +++ b/web/app/templates/main/dashboard.html.j2 @@ -28,8 +28,6 @@
    diff --git a/web/app/templates/playground/index.html.j2 b/web/app/templates/playground/index.html.j2 index 440e4cf7..7ed676de 100644 --- a/web/app/templates/playground/index.html.j2 +++ b/web/app/templates/playground/index.html.j2 @@ -1,7 +1,179 @@ {% extends "nopaque.html.j2" %} +{% set headline = 'Workflow' %} + {% block page_content %} +
    +
    Your data
    +
    +
    +
    +
    +

    + account_circle +

    + You +
    +
    +
    +
    +
    Your goals
    +
    +
    -

    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, no sea takimata sanctus est Lorem ipsum dolor sit amet.

    +

    Process your data with nopaque

    +
    + +
    + +
    +
    +
    + + + + File setup

    + Prepare images for further processing + trending_flat +
    +
    +
    + +
    +
    +
    + + + + Optical Character Recognition + Convert image data into machine readable text + trending_flat +
    +
    +
    + +
    +
    +
    + + + + Natural Language Processing + Append linguistic informations to your text +
    +
    +
    + +
    +
    +
    + More information +

    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, no sea takimata sanctus est Lorem ipsum dolor sit amet. 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, no sea takimata sanctus est Lorem ipsum dolor sit amet. 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, no sea takimata sanctus est Lorem ipsum dolor sit amet.

    +

    Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.

    +

    Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse

    +
    +
    +
    + +
    +
    +
    + More information +

    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, no sea takimata sanctus est Lorem ipsum dolor sit amet. 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, no sea takimata sanctus est Lorem ipsum dolor sit amet. 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, no sea takimata sanctus est Lorem ipsum dolor sit amet.

    +

    Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.

    +

    Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse

    +
    +
    +
    + +
    +
    +
    + More information +

    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, no sea takimata sanctus est Lorem ipsum dolor sit amet. 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, no sea takimata sanctus est Lorem ipsum dolor sit amet. 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, no sea takimata sanctus est Lorem ipsum dolor sit amet.

    +

    Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.

    +

    Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse

    +
    +
    +
    + + + +
    +

    Research process

    +
    + +
    + +
    +
    +
    + + + + Corpus analysis + Create as many text corpora as you want. It makes use of CQP Query Language, which allows for complex search requests with the aid of metadata and NLP tags. +
    +
    +
    + +
    + +
    +
    +
    + Publish + Get information from your texts and open up new perspectives, this may lead to further analysis ideas. +
    +
    +
    + +
    +
    +
    + Enlightment + Get information from your texts and open up new perspectives, this may lead to further analysis ideas. +
    +
    +
    + +
    +
    +
    + Import/Export results + You can export your query results and share it with others or view results from your research partners. +
    +
    +
    + +
    +
    +
    + Stuff + You can export your query results and share it with others or view results from your research partners. +
    +
    {% endblock %} diff --git a/web/app/templates/results/result_details.html.j2 b/web/app/templates/results/result_details.html.j2 deleted file mode 100644 index 7a85aa4a..00000000 --- a/web/app/templates/results/result_details.html.j2 +++ /dev/null @@ -1,119 +0,0 @@ -{% extends "nopaque.html.j2" %} - -{% block page_content %} - - -
    -

    Below the metadata for the results from the Corpus - {{ result.corpus_metadata.corpus_name }} generated with the query - {{ result.corpus_metadata.query }} are shown. -

    -

    {{ texts_metadata }}

    -
    - -
    -
    -
    - - - - - - - - - {% for pair in result.corpus_metadata|dictsort %} - - - {% if pair[0] == 'corpus_all_texts' - or pair[0] == 'text_lookup' %} - - {% else %} - - {% endif %} - - {% endfor %} - -
    Metadata DescriptionValue
    {{ pair[0] }} - - {% for key, value in pair[1].items() %} - - - - {% endfor %} -
    - {{ value['title'] }} written - by {{ value['author'] }} - in {{ value['publishing_year'] }} - More - - info_outline - - -
    -
    {{ pair[1] }}
    -
    - -
    -
    - - - - - - -{% endblock %} diff --git a/web/app/templates/results/result_import.html.j2 b/web/app/templates/results/result_import.html.j2 deleted file mode 100644 index f1e1d41f..00000000 --- a/web/app/templates/results/result_import.html.j2 +++ /dev/null @@ -1,39 +0,0 @@ -{% extends "nopaque.html.j2" %} - -{% block page_content %} -
    -

    Fill out the following form to upload and view Results and Sub Results - exported from the Corpus analsis Tool.

    - arrow_backBack to dashboard -
    - -
    -
    -
    -
    - {{ import_results_form.hidden_tag() }} -
    -
    - {{ M.render_field(import_results_form.file, accept='.json', placeholder='Choose your .json file') }} -
    -
    -
    -
    - {{ M.render_field(import_results_form.submit, material_icon='send') }} -
    -
    -
    -
    - - -{% endblock %} diff --git a/web/app/templates/results/result_inspect.html.j2 b/web/app/templates/results/result_inspect.html.j2 deleted file mode 100644 index e28b964a..00000000 --- a/web/app/templates/results/result_inspect.html.j2 +++ /dev/null @@ -1,281 +0,0 @@ -{% extends "nopaque.html.j2" %} - -{% set headline = ' ' %} - -{% set full_width = True %} - -{% block page_content %} -
    -
    -
    -
    -
    -
    -
    Infos
    -
    -
    -

    - Displaying - - of - - matches. -
    - Matches occured in - - corpus files: -
    - -

    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    Display
    -
    -
    -
    -
    - {{ M.render_field(display_options_form.results_per_page, - material_icon='format_list_numbered') }} - {{ M.render_field(display_options_form.result_context, - material_icon='short_text') }} - {{ M.render_field(display_options_form.expert_mode) }} -
    -
    -
    -
    -
    -
    -
    - -
    -
      - - - - - - - - - - - - - -
      Nr.TitleLeft contextMatchActionsRight Context
      -
        -
        -
        -
        -
        - - - - - - - - - -{% endblock %} \ No newline at end of file diff --git a/web/app/templates/results/results.html.j2 b/web/app/templates/results/results.html.j2 deleted file mode 100644 index ecf8095a..00000000 --- a/web/app/templates/results/results.html.j2 +++ /dev/null @@ -1,71 +0,0 @@ -{% extends "nopaque.html.j2" %} - -{% set full_width = True %} - -{% block page_content %} - -
        -

        This is an overview of all your imported results.

        -
        - -
        -
        -
        -
        - search - - -
        -
          - - - - - - - - - - - - - - - - - -
          QueryMatch countCorpus nameCorpus creation dateCorpus analysis dateCorpus type{# Actions #}
          - folderNothing here... -

          No results yet imported.

          -
          -
            -
            - -
            -
            - -{# Delete modals #} -{% for result in results %} - -{% endfor %} - - -{% endblock %} diff --git a/web/app/templates/services/corpus_analysis.html.j2 b/web/app/templates/services/corpus_analysis.html.j2 index ff416fc7..ce93c8e0 100644 --- a/web/app/templates/services/corpus_analysis.html.j2 +++ b/web/app/templates/services/corpus_analysis.html.j2 @@ -37,8 +37,6 @@
              diff --git a/web/migrations/versions/c3827cddea6e_.py b/web/migrations/versions/c3827cddea6e_.py new file mode 100644 index 00000000..61e156d9 --- /dev/null +++ b/web/migrations/versions/c3827cddea6e_.py @@ -0,0 +1,43 @@ +"""empty message + +Revision ID: c3827cddea6e +Revises: 9d21b228d353 +Create Date: 2020-07-15 12:33:24.574579 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = 'c3827cddea6e' +down_revision = '9d21b228d353' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('results') + op.drop_table('result_files') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('result_files', + sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column('result_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('filename', sa.VARCHAR(length=255), autoincrement=False, nullable=True), + sa.Column('dir', sa.VARCHAR(length=255), autoincrement=False, nullable=True), + sa.ForeignKeyConstraint(['result_id'], ['results.id'], name='result_files_result_id_fkey'), + sa.PrimaryKeyConstraint('id', name='result_files_pkey') + ) + op.create_table('results', + sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('corpus_metadata', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='results_user_id_fkey'), + sa.PrimaryKeyConstraint('id', name='results_pkey') + ) + # ### end Alembic commands ### diff --git a/web/nopaque.py b/web/nopaque.py index b19c3b87..56b2bbeb 100644 --- a/web/nopaque.py +++ b/web/nopaque.py @@ -3,7 +3,7 @@ eventlet.monkey_patch() # noqa from app import create_app, db, socketio from app.models import (Corpus, CorpusFile, Job, JobInput, JobResult, NotificationData, NotificationEmailData, QueryResult, - Result, ResultFile, Role, User) + Role, User) from flask_migrate import Migrate, upgrade import os @@ -22,8 +22,6 @@ def make_shell_context(): 'NotificationData': NotificationData, 'NotificationEmailData': NotificationEmailData, 'QueryResult': QueryResult, - 'Result': Result, - 'ResultFile': ResultFile, 'Role': Role, 'User': User}