parent
e9e8e94075
commit
51b1237b5f
@ -0,0 +1,83 @@
|
||||
"""Added tables for Solar data and authentication.
|
||||
|
||||
Revision ID: c6edf87b8bff
|
||||
Revises: a846faa2b908
|
||||
Create Date: 2021-05-03 10:12:50.632988
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c6edf87b8bff'
|
||||
down_revision = 'a846faa2b908'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('upload_solar')
|
||||
op.drop_table('institution')
|
||||
op.drop_table('stamps')
|
||||
op.drop_table('registered_user')
|
||||
op.drop_column('upload_unauthenticated', 'corpus_name')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('upload_unauthenticated', sa.Column('corpus_name', sa.TEXT(), autoincrement=False, nullable=False))
|
||||
op.create_table('institution',
|
||||
sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('institution_id_seq'::regclass)"), autoincrement=True, nullable=False),
|
||||
sa.Column('name', sa.TEXT(), autoincrement=False, nullable=False),
|
||||
sa.Column('region', sa.TEXT(), autoincrement=False, nullable=False),
|
||||
sa.Column('file_contract', sa.TEXT(), autoincrement=False, nullable=True),
|
||||
sa.PrimaryKeyConstraint('id', name='institution_pkey'),
|
||||
postgresql_ignore_search_path=False
|
||||
)
|
||||
op.create_table('registered_user',
|
||||
sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('registered_user_id_seq'::regclass)"), autoincrement=True, nullable=False),
|
||||
sa.Column('name', sa.TEXT(), autoincrement=False, nullable=False),
|
||||
sa.Column('email', sa.TEXT(), autoincrement=False, nullable=False),
|
||||
sa.Column('role', sa.TEXT(), autoincrement=False, nullable=False),
|
||||
sa.Column('pass_hash', sa.TEXT(), autoincrement=False, nullable=False),
|
||||
sa.Column('active', sa.BOOLEAN(), autoincrement=False, nullable=True),
|
||||
sa.Column('last_login', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
|
||||
sa.Column('registered', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
|
||||
sa.Column('institution', sa.INTEGER(), autoincrement=False, nullable=True),
|
||||
sa.ForeignKeyConstraint(['institution'], ['institution.id'], name='registered_user_institution_fkey'),
|
||||
sa.PrimaryKeyConstraint('id', name='registered_user_pkey'),
|
||||
postgresql_ignore_search_path=False
|
||||
)
|
||||
op.create_table('stamps',
|
||||
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('institution', sa.INTEGER(), autoincrement=False, nullable=True),
|
||||
sa.Column('name', sa.TEXT(), autoincrement=False, nullable=False),
|
||||
sa.Column('file_logo', sa.TEXT(), autoincrement=False, nullable=True),
|
||||
sa.ForeignKeyConstraint(['institution'], ['institution.id'], name='stamps_institution_fkey'),
|
||||
sa.PrimaryKeyConstraint('id', name='stamps_pkey')
|
||||
)
|
||||
op.create_table('upload_solar',
|
||||
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('upload_user', sa.INTEGER(), autoincrement=False, nullable=True),
|
||||
sa.Column('institution', sa.INTEGER(), autoincrement=False, nullable=True),
|
||||
sa.Column('upload_hash', sa.TEXT(), autoincrement=False, nullable=False),
|
||||
sa.Column('timestamp', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
|
||||
sa.Column('corpus_name', sa.TEXT(), autoincrement=False, nullable=False),
|
||||
sa.Column('form_program', sa.TEXT(), autoincrement=False, nullable=True),
|
||||
sa.Column('form_subject', sa.TEXT(), autoincrement=False, nullable=True),
|
||||
sa.Column('form_grade', sa.INTEGER(), autoincrement=False, nullable=True),
|
||||
sa.Column('form_text_type', sa.TEXT(), autoincrement=False, nullable=True),
|
||||
sa.Column('form_school_year', sa.TEXT(), autoincrement=False, nullable=True),
|
||||
sa.Column('form_grammar_corrections', sa.TEXT(), autoincrement=False, nullable=True),
|
||||
sa.Column('upload_file_hashes', sa.ARRAY(sa.String()), nullable=True),
|
||||
sa.ForeignKeyConstraint(['upload_user'], ['registered_user.id'], name='upload_upload_user_fkey'),
|
||||
sa.ForeignKeyConstraint(['institution'], ['institution.id'], name='upload_institution_fkey'),
|
||||
sa.PrimaryKeyConstraint('id', name='upload_pkey')
|
||||
)
|
||||
|
||||
# Insert default admin user with username "admin" and pass "portal-admin".
|
||||
op.execute('INSERT INTO registered_user(name, email, role, pass_hash, active) VALUES (\'admin\', \'admin@cjvt.si\', \'admin\', \'pbkdf2:sha256:150000$aPRDrEqF$f27256d6d57001770feb9e7012ea27252f4a3e5ea9989931368e466d798679ff\', TRUE);')
|
||||
# ### end Alembic commands ###
|
@ -0,0 +1,41 @@
|
||||
import portal.base
|
||||
|
||||
|
||||
def handle_upload(request, upload_handler):
|
||||
files = request.files
|
||||
if len(files) > upload_handler.MAX_FILES_PER_UPLOAD:
|
||||
return 'Naložite lahko do {} datotek hkrati.'.format(upload_handler.MAX_FILES_PER_UPLOAD), 400
|
||||
elif len(files) < 1:
|
||||
return 'Priložena ni bila nobena datoteka.', 400
|
||||
|
||||
err = portal.base.check_suffixes(files)
|
||||
if err:
|
||||
return err, 400
|
||||
|
||||
err = check_form(request.form)
|
||||
if err:
|
||||
return err, 400
|
||||
|
||||
# Parse request.
|
||||
upload_metadata = upload_handler.extract_upload_metadata(corpus_name, request)
|
||||
|
||||
logging.info('Upload from user "{}" with upload id "{}" supplied form data: {}'.format(
|
||||
request.user,
|
||||
upload_metadata['upload_id'],
|
||||
str(upload_metadata['form_data']
|
||||
)))
|
||||
|
||||
# Store uploaded files to disk.
|
||||
upload_handler.store_datafiles(files, upload_metadata)
|
||||
|
||||
# Store metadata to database.
|
||||
upload_handler.store_metadata_solar(upload_metadata)
|
||||
|
||||
# Send confirmation mail along with the contract to the submitted email address.
|
||||
upload_handler.send_confirm_mail(upload_metadata)
|
||||
|
||||
return 'Uspešno ste oddali datotek(e). Št. datotek: {}'.format(len(files))
|
||||
|
||||
|
||||
def check_form(form):
|
||||
pass
|
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h3>Login</h3>
|
||||
<div>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<div>
|
||||
{{ messages[0] }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
<form method="POST" action="/{{corpus_name}}/login">
|
||||
<div>
|
||||
<div>
|
||||
<input type="email" name="email" placeholder="Your Email" autofocus="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div>
|
||||
<input type="password" name="password" placeholder="Your Password">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox">
|
||||
Remember me
|
||||
</label>
|
||||
</div>
|
||||
<button>Login</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
Loading…
Reference in new issue