crunk
6 months ago
38 changed files with 1396 additions and 1358 deletions
@ -1,25 +1,49 @@ |
|||
[tool.black] |
|||
[tool.ruff] |
|||
line-length = 79 |
|||
target-version = ['py311'] |
|||
include = '\.pyi?$' |
|||
exclude = ''' |
|||
/( |
|||
\.eggs |
|||
| \.git |
|||
| \.hg |
|||
| \.mypy_cache |
|||
| \.tox |
|||
| \.venv |
|||
| _build |
|||
| buck-out |
|||
| build |
|||
| dist |
|||
|
|||
# The following are specific to Black, you probably don't want those. |
|||
| blib2to3 |
|||
| tests/data |
|||
| profiling |
|||
)/ |
|||
''' |
|||
target-version = "py311" |
|||
#include = '\.pyi?$' |
|||
exclude = [ |
|||
".bzr", |
|||
".direnv", |
|||
".eggs", |
|||
".git", |
|||
".git-rewrite", |
|||
".hg", |
|||
".ipynb_checkpoints", |
|||
".mypy_cache", |
|||
".nox", |
|||
".pants.d", |
|||
".pyenv", |
|||
".pytest_cache", |
|||
".pytype", |
|||
".ruff_cache", |
|||
".svn", |
|||
".tox", |
|||
".venv", |
|||
".vscode", |
|||
"__pypackages__", |
|||
"_build", |
|||
"buck-out", |
|||
"build", |
|||
"dist", |
|||
"node_modules", |
|||
"site-packages", |
|||
"venv", |
|||
] |
|||
|
|||
[tool.ruff.lint] |
|||
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. |
|||
select = ["E4", "E7", "E9", "F"] |
|||
ignore = [] |
|||
# Allow fix for all enabled rules (when `--fix`) is provided. |
|||
fixable = ["ALL"] |
|||
unfixable = [] |
|||
# Allow unused variables when underscore-prefixed. |
|||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" |
|||
|
|||
[tool.ruff.format] |
|||
quote-style = "double" |
|||
indent-style = "tab" |
|||
docstring-code-format = true |
|||
line-ending = "auto" |
|||
skip-magic-trailing-comma = false |
|||
|
@ -1,23 +1,23 @@ |
|||
def deploy(): |
|||
"""Run deployment of database.""" |
|||
from flask_migrate import init, migrate, stamp, upgrade |
|||
"""Run deployment of database.""" |
|||
from flask_migrate import init, migrate, stamp, upgrade |
|||
|
|||
from app import create_app, db |
|||
from models.distribusi_model import Distribusis # noqa: F401 |
|||
from models.distribusi_file_model import DistribusiFiles # noqa: F401 |
|||
from app import create_app, db |
|||
from models.distribusi_model import Distribusis # noqa: F401 |
|||
from models.distribusi_file_model import DistribusiFiles # noqa: F401 |
|||
|
|||
# This model is required for flask_migrate to make the table |
|||
from models.user_model import User # noqa: F401 |
|||
# This model is required for flask_migrate to make the table |
|||
from models.user_model import User # noqa: F401 |
|||
|
|||
app = create_app() |
|||
app.app_context().push() |
|||
db.create_all() |
|||
app = create_app() |
|||
app.app_context().push() |
|||
db.create_all() |
|||
|
|||
# migrate database to latest revision |
|||
init() |
|||
stamp() |
|||
migrate() |
|||
upgrade() |
|||
# migrate database to latest revision |
|||
init() |
|||
stamp() |
|||
migrate() |
|||
upgrade() |
|||
|
|||
|
|||
deploy() |
|||
|
@ -1,85 +1,85 @@ |
|||
from flask_wtf import FlaskForm |
|||
from flask_wtf.file import FileAllowed, FileField, FileRequired, FileSize |
|||
from wtforms import ( |
|||
SelectField, |
|||
StringField, |
|||
SubmitField, |
|||
validators, |
|||
SelectField, |
|||
StringField, |
|||
SubmitField, |
|||
validators, |
|||
) |
|||
from wtforms.validators import ( |
|||
DataRequired, |
|||
Length, |
|||
ValidationError, |
|||
DataRequired, |
|||
Length, |
|||
ValidationError, |
|||
) |
|||
|
|||
from app import settings |
|||
|
|||
|
|||
class UploadForm(FlaskForm): |
|||
"""File upload class for a new site in distribusi-verse""" |
|||
"""File upload class for a new site in distribusi-verse""" |
|||
|
|||
def distribusiname(form, field): |
|||
if field.data.lower() == "new": |
|||
raise ValidationError("Name has to be unique and not just new.") |
|||
def distribusiname(form, field): |
|||
if field.data.lower() == "new": |
|||
raise ValidationError("Name has to be unique and not just new.") |
|||
|
|||
def category_choices(): |
|||
APP = settings() |
|||
config_categories = APP.config["categories"] |
|||
categories = [] |
|||
for config_category in config_categories: |
|||
categories.append((config_category, config_category)) |
|||
return categories |
|||
def category_choices(): |
|||
APP = settings() |
|||
config_categories = APP.config["categories"] |
|||
categories = [] |
|||
for config_category in config_categories: |
|||
categories.append((config_category, config_category)) |
|||
return categories |
|||
|
|||
def year_choices(): |
|||
APP = settings() |
|||
start_time = APP.config["start_time"] |
|||
end_time = APP.config["end_time"] |
|||
year_range = range(start_time.year, end_time.year, 1) |
|||
year_choices = [] |
|||
for year in year_range: |
|||
year_choices.append((str(year), str(year))) |
|||
return year_choices |
|||
def year_choices(): |
|||
APP = settings() |
|||
start_time = APP.config["start_time"] |
|||
end_time = APP.config["end_time"] |
|||
year_range = range(start_time.year, end_time.year, 1) |
|||
year_choices = [] |
|||
for year in year_range: |
|||
year_choices.append((str(year), str(year))) |
|||
return year_choices |
|||
|
|||
sitename = StringField( |
|||
"Name of your archive section:", |
|||
validators=[ |
|||
validators.InputRequired(), |
|||
Length(2, 100), |
|||
distribusiname, |
|||
], |
|||
) |
|||
year = SelectField( |
|||
"Year:", |
|||
validate_choice=True, |
|||
coerce=str, |
|||
choices=year_choices, |
|||
option_widget=None, |
|||
validators=[DataRequired()], |
|||
) |
|||
category = SelectField( |
|||
"Category:", |
|||
validate_choice=True, |
|||
coerce=str, |
|||
choices=category_choices, |
|||
option_widget=None, |
|||
validators=[DataRequired()], |
|||
) |
|||
sitename = StringField( |
|||
"Name of your archive section:", |
|||
validators=[ |
|||
validators.InputRequired(), |
|||
Length(2, 100), |
|||
distribusiname, |
|||
], |
|||
) |
|||
year = SelectField( |
|||
"Year:", |
|||
validate_choice=True, |
|||
coerce=str, |
|||
choices=year_choices, |
|||
option_widget=None, |
|||
validators=[DataRequired()], |
|||
) |
|||
category = SelectField( |
|||
"Category:", |
|||
validate_choice=True, |
|||
coerce=str, |
|||
choices=category_choices, |
|||
option_widget=None, |
|||
validators=[DataRequired()], |
|||
) |
|||
|
|||
tags = StringField( |
|||
"Add search tags, seperated by commas. No need for the '#' sign:", |
|||
validators=[validators.InputRequired(), Length(3, 500)], |
|||
) |
|||
tags = StringField( |
|||
"Add search tags, seperated by commas. No need for the '#' sign:", |
|||
validators=[validators.InputRequired(), Length(3, 500)], |
|||
) |
|||
|
|||
zipfile = FileField( |
|||
"Upload your zip file with content here:", |
|||
validators=[ |
|||
FileAllowed(["zip"], "Zip archives only!"), |
|||
FileRequired(), |
|||
FileSize( |
|||
max_size=1073741824, |
|||
message="Zipfile size must be smaller than 100MB", |
|||
), |
|||
], |
|||
) |
|||
zipfile = FileField( |
|||
"Upload your zip file with content here:", |
|||
validators=[ |
|||
FileAllowed(["zip"], "Zip archives only!"), |
|||
FileRequired(), |
|||
FileSize( |
|||
max_size=1073741824, |
|||
message="Zipfile size must be smaller than 100MB", |
|||
), |
|||
], |
|||
) |
|||
|
|||
submit = SubmitField("Upload") |
|||
submit = SubmitField("Upload") |
|||
|
Loading…
Reference in new issue