Browse Source

ruff refactoring

pull/12/head
crunk 6 months ago
parent
commit
bbf2fcf047
  1. 1
      verse/app.py
  2. 6
      verse/describer/describe_files.py
  3. 4
      verse/describer/forms/describe_file_form.py
  4. 2
      verse/describer/templates/describe_files/describe.html
  5. 1
      verse/distribusikan/distribusikan.py
  6. 4
      verse/distribusikan/distribusiselector.py
  7. 2
      verse/file_crawler.py
  8. 2
      verse/forms/registerform.py
  9. 2
      verse/forms/uploadform.py
  10. 1
      verse/start.py
  11. 2
      verse/statuspengguna/loginuser.py
  12. 3
      verse/statuspengguna/resetpassword.py

1
verse/app.py

@ -64,7 +64,6 @@ def get_app():
def settings_from_file(): def settings_from_file():
settings = {}
if os.path.isfile("settings_development.toml"): if os.path.isfile("settings_development.toml"):
with open("settings_development.toml", "rb") as settings_file: with open("settings_development.toml", "rb") as settings_file:
return tomllib.load(settings_file) return tomllib.load(settings_file)

6
verse/describer/describe_files.py

@ -1,4 +1,5 @@
from flask import Blueprint, render_template from flask import Blueprint, render_template, redirect, url_for
from flask_login import current_user
from models.distribusi_model import Distribusis from models.distribusi_model import Distribusis
from models.distribusi_file_model import DistribusiFiles from models.distribusi_file_model import DistribusiFiles
@ -12,11 +13,12 @@ describer = Blueprint(
@describer.route("/<string:distribusiname>") @describer.route("/<string:distribusiname>")
def describe_distribusi_files(distribusiname): def describe_distribusi_files(distribusiname):
if not current_user.is_authenticated:
return redirect(url_for("index"))
distribusi = Distribusis.query.filter_by( distribusi = Distribusis.query.filter_by(
distribusiname=distribusiname distribusiname=distribusiname
).first() ).first()
distribusi_files = DistribusiFiles.query.filter_by( distribusi_files = DistribusiFiles.query.filter_by(
distribusi=distribusi.id distribusi=distribusi.id
).all() ).all()
print(distribusi_files)
return render_template("describe.html", distribusi_files=distribusi_files) return render_template("describe.html", distribusi_files=distribusi_files)

4
verse/describer/forms/describe_file_form.py

@ -1,8 +1,8 @@
"""Describe File Form to describe files in the distribusi archive""" """Describe File Form to describe files in the distribusi archive"""
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField from wtforms import StringField, SubmitField, validators
from wtforms.validators import Length
class DescribeFileForm(FlaskForm): class DescribeFileForm(FlaskForm):
"""DescribeFileForm selection form.""" """DescribeFileForm selection form."""

2
verse/describer/templates/describe_files/describe.html

@ -28,7 +28,7 @@
</div> </div>
<div class="distribusi_files"> <div class="distribusi_files">
{% for file in distribusi_files %} {% for file in distribusi_files %}
<p>{{file}}</p> <p>{{file.path}}</p>
{% endfor%} {% endfor%}
</div> </div>
{% endblock %} {% endblock %}

1
verse/distribusikan/distribusikan.py

@ -4,7 +4,6 @@ from flask_login import login_required
from distribusikan.distribusiselector import DistribusiSelector from distribusikan.distribusiselector import DistribusiSelector
# Distribusi Information # Distribusi Information
from distribusikan.distribusisinfo import DistribusisInfo
from distribusikan.distribusiworkflow import DistribusiWorkflow from distribusikan.distribusiworkflow import DistribusiWorkflow
from distribusikan.editor import Editor from distribusikan.editor import Editor
from distribusikan.themeselector import ThemeSelector from distribusikan.themeselector import ThemeSelector

4
verse/distribusikan/distribusiselector.py

@ -10,9 +10,8 @@ from sqlalchemy.exc import (
InvalidRequestError, InvalidRequestError,
) )
from app import db, get_app from app import db
from distribusikan.distribusisinfo import DistribusisInfo from distribusikan.distribusisinfo import DistribusisInfo
from describer.describe_files import describe_distribusi_files
from forms.distribusiform import DistribusiForm from forms.distribusiform import DistribusiForm
from forms.publicthemeform import PublicThemeForm from forms.publicthemeform import PublicThemeForm
from forms.selectorform import SelectorForm from forms.selectorform import SelectorForm
@ -68,7 +67,6 @@ def SelectNewDistribusi():
def SelectDescribeDistribusi(distribusiname): def SelectDescribeDistribusi(distribusiname):
app = get_app
return redirect( return redirect(
url_for( url_for(
"describer.describe_distribusi_files", "describer.describe_distribusi_files",

2
verse/file_crawler.py

@ -1,7 +1,7 @@
import os import os
import magic import magic
from distribusi.mappings import CODE_TYPES, FILE_TYPES, SUB_TYPES from distribusi.mappings import FILE_TYPES
from models.distribusi_model import Distribusis from models.distribusi_model import Distribusis
from models.distribusi_file_model import DistribusiFiles from models.distribusi_file_model import DistribusiFiles
from app import create_app, get_app, db from app import create_app, get_app, db

2
verse/forms/registerform.py

@ -2,7 +2,7 @@
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import PasswordField, StringField, SubmitField, validators from wtforms import PasswordField, StringField, SubmitField, validators
from wtforms.validators import Email, EqualTo, Length, ValidationError from wtforms.validators import Email, EqualTo, Length
class RegisterForm(FlaskForm): class RegisterForm(FlaskForm):

2
verse/forms/uploadform.py

@ -1,7 +1,6 @@
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from flask_wtf.file import FileAllowed, FileField, FileRequired, FileSize from flask_wtf.file import FileAllowed, FileField, FileRequired, FileSize
from wtforms import ( from wtforms import (
IntegerField,
SelectField, SelectField,
StringField, StringField,
SubmitField, SubmitField,
@ -10,7 +9,6 @@ from wtforms import (
from wtforms.validators import ( from wtforms.validators import (
DataRequired, DataRequired,
Length, Length,
NumberRange,
ValidationError, ValidationError,
) )

1
verse/start.py

@ -5,7 +5,6 @@ from datetime import timedelta
from flask import (Blueprint, redirect, render_template, send_from_directory, from flask import (Blueprint, redirect, render_template, send_from_directory,
session, url_for) session, url_for)
from flask_login import current_user, login_required, logout_user from flask_login import current_user, login_required, logout_user
from flask_mail import Mail
from flask_wtf.csrf import CSRFError from flask_wtf.csrf import CSRFError
from adminpage import AdminPage from adminpage import AdminPage

2
verse/statuspengguna/loginuser.py

@ -5,8 +5,6 @@ from flask import (
redirect, redirect,
render_template, render_template,
request, request,
send_from_directory,
session,
url_for, url_for,
) )
from flask_bcrypt import check_password_hash from flask_bcrypt import check_password_hash

3
verse/statuspengguna/resetpassword.py

@ -1,6 +1,6 @@
from datetime import datetime from datetime import datetime
from flask import flash, redirect, render_template, url_for from flask import Blueprint, flash, redirect, render_template, url_for
from flask_bcrypt import generate_password_hash from flask_bcrypt import generate_password_hash
from flask_login import login_user from flask_login import login_user
from sqlalchemy.exc import ( from sqlalchemy.exc import (
@ -15,7 +15,6 @@ from werkzeug.routing import BuildError
from app import db from app import db
from forms.resetpasswordform import ResetPasswordForm from forms.resetpasswordform import ResetPasswordForm
from models.user_model import User from models.user_model import User
from statuspengguna import statuspengguna
reset_password = Blueprint( reset_password = Blueprint(
"reset_password", "reset_password",

Loading…
Cancel
Save