Skip to content

Commit

Permalink
Assorted fixes (#51)
Browse files Browse the repository at this point in the history
* Replace label for theses search

'Архив курсовых и ВКР' -> 'Архив практик и ВКР'

* Fix requirements conflicts

* Update requirements
* Fix "Working outside of application context" in db_init()
* Change default instance folder from `instance` to `databases`
* Untrack `__pycache__` folders
* Add workflow file with basic serviceability checks
* Fix linter issues
* Update version of checkout action in linter workflow

* Add dependabot PRs grouping
  • Loading branch information
vkutuev committed Jul 11, 2023
1 parent b7ce6a2 commit ed691eb
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 42 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ updates:
directory: "/"
schedule:
interval: "monthly"
groups:
pip-dependencies:
patterns:
- "*" # All dependabot updates are grouped
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
options: "--check --verbose --diff --exclude '/migrations'"
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/serviceability.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Basic checks

on: [push, pull_request]

jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.8, 3.9 ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies
- name: Install requirements # Check problems with dependencies
run: python -m pip install -r requirements.txt
- name: Init databases # Check basic scenario -- database initialization
working-directory: src
run: python flask_se.py init
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,7 @@ fabric.properties
flask_se_secret.conf
/**/flask_se_mail.conf
*/src/flask_se_mail.conf
flask_se_mail.conf
flask_se_mail.conf

# Do not track __pycache__
**/__pycache__/
42 changes: 28 additions & 14 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,60 +1,74 @@
alembic==1.11.1
APScheduler==3.8.1
attrs==23.1.0
backports.zoneinfo==0.2.1
beautifulsoup4==4.9.3
blinker==1.6.2
bs4==0.0.1
cachetools==5.3.1
certifi==2023.5.7
chardet==4.0.0
charset-normalizer==3.1.0
click==8.0.0
click==8.1.3
clickclick==20.10.2
connexion==2.6.0
Flask==2.3.2
Flask-Admin==1.5.8
Flask-Admin==1.6.1
Flask-APScheduler==1.12.4
Flask-BasicAuth==0.2.0
Flask-Login==0.5.0
Flask-Login==0.6.2
Flask-Markdown==0.3
Flask-Migrate==3.0.1
flask-msearch==0.2.9.2
Flask-SimpleMDE==0.3.0
Flask-SQLAlchemy==2.5.1
Flask-WTF==0.14.3
Flask-SQLAlchemy==3.0.5
Flask-WTF==1.1.1
Frozen-Flask==0.15
google-auth==2.21.0
google-auth-oauthlib==0.7.1
greenlet==2.0.2
html5lib==1.1
idna==3.3
importlib-metadata==6.7.0
importlib-resources==5.12.0
inflection==0.5.1
itsdangerous==2.0.1
Jinja2==3.0.3
itsdangerous==2.1.2
Jinja2==3.1.2
jsonschema==4.17.3
Mako==1.2.4
Markdown==3.4.3
MarkupSafe==2.1.2
oauthlib==3.2.2
openapi-schema-validator==0.2.3
openapi-spec-validator==0.4.0
packaging==21.3
Pillow==9.3.0
pkgutil_resolve_name==1.3.10
pyasn1==0.5.0
pyasn1-modules==0.3.0
PyMuPDF==1.22.3
pyparsing==3.0.8
pyrsistent==0.18.1
python-dateutil==2.8.2
python-editor==1.0.4
pytz==2022.1
pytz-deprecation-shim==0.1.0.post0
PyMuPDF==1.22.3
PyYAML==6.0
regex==2023.6.3
requests==2.31.0
requests-oauthlib==1.3.1
rsa==4.9
six==1.16.0
soupsieve==2.3.2.post1
SQLAlchemy==2.0.15
textile==4.0.2
transliterate==1.10.2
typing_extensions==4.7.1
tzdata==2022.1
tzlocal==4.2
urllib3==1.26.9
webencodings==0.5.1
Werkzeug==2.3.4
Whoosh==2.7.4
WTForms==3.0.1
transliterate==1.10.2
Pillow==9.3.0
google-auth-oauthlib==0.7.1
textile==4.0.2
whoosh==2.7.4
pip==22.3.1
zipp==3.7.0
13 changes: 8 additions & 5 deletions src/flask_se.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@
)

app = Flask(
__name__, static_url_path="", static_folder="static", template_folder="templates"
__name__,
static_url_path="",
static_folder="static",
template_folder="templates",
instance_path=SQLITE_DATABASE_PATH,
)

# Flask configs
Expand All @@ -157,9 +161,7 @@
app.config["FREEZER_IGNORE_MIMETYPE_WARNINGS"] = True

# SQLAlchimy config
app.config["SQLALCHEMY_DATABASE_URI"] = (
"sqlite:///" + SQLITE_DATABASE_PATH + SQLITE_DATABASE_NAME
)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + SQLITE_DATABASE_NAME
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
app.config["SECRET_KEY"] = SECRET_KEY
app.config["SESSION_COOKIE_NAME"] = "se_session"
Expand Down Expand Up @@ -683,6 +685,7 @@ def sitemap():
if sys.argv[1] == "build":
freezer.freeze()
elif sys.argv[1] == "init":
init_db()
with app.app_context():
init_db()
else:
app.run(port=5000, debug=True)
32 changes: 30 additions & 2 deletions src/flask_se_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,36 @@ def inaccessible_callback(self, name, **kwargs):


class SeAdminModelViewUsers(SeAdminModelView):
column_exclude_list = ["password_hash", "internship_author", "current_thesises", "diploma_themes_author", "diploma_themes_consultant", "diploma_themes_thesis_supervisor", "diploma_themes_supervisor", "news", "staff", "all_user_votes", "reviewer", "thesis_on_review_author", "thesises"]
form_excluded_columns = ["password_hash", "internship_author", "current_thesises", "diploma_themes_author", "diploma_themes_consultant", "diploma_themes_thesis_supervisor", "diploma_themes_supervisor", "news", "staff", "all_user_votes", "reviewer", "thesis_on_review_author", "thesises"]
column_exclude_list = [
"password_hash",
"internship_author",
"current_thesises",
"diploma_themes_author",
"diploma_themes_consultant",
"diploma_themes_thesis_supervisor",
"diploma_themes_supervisor",
"news",
"staff",
"all_user_votes",
"reviewer",
"thesis_on_review_author",
"thesises",
]
form_excluded_columns = [
"password_hash",
"internship_author",
"current_thesises",
"diploma_themes_author",
"diploma_themes_consultant",
"diploma_themes_thesis_supervisor",
"diploma_themes_supervisor",
"news",
"staff",
"all_user_votes",
"reviewer",
"thesis_on_review_author",
"thesises",
]

pass

Expand Down
4 changes: 3 additions & 1 deletion src/flask_se_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def login_index():
password = request.form.get("password")
user = Users.query.filter_by(email=email).first()
if user:
if (user.password_hash is not None) and check_password_hash(user.password_hash, password):
if (user.password_hash is not None) and check_password_hash(
user.password_hash, password
):
login_user(user, remember=True)
return redirect_next_url(fallback=url_for("user_profile"))
else:
Expand Down
2 changes: 1 addition & 1 deletion src/flask_se_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)
SECRET_KEY_THESIS = os.urandom(16).hex()
SQLITE_DATABASE_NAME = "se.db"
SQLITE_DATABASE_PATH = "databases/"
SQLITE_DATABASE_PATH = pathlib.Path("databases/").absolute().as_posix()

if os.path.exists(MAIL_PASSWORD_FILE):
with open(MAIL_PASSWORD_FILE, "r") as file:
Expand Down
2 changes: 1 addition & 1 deletion src/templates/bachelor_admission.html
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ <h6 class="mb-0"><strong>{{ t.name_ru }} [{{ t.publish_year }}]</strong></h6>
<div class="row pt-2">
<div class="col-lg-12 pr-0 text-center">
<a href="{{ url_for('theses_search') }}" class="btn btn-lg btn-secondary btn-icon mb-3 mb-lg-0">
<span class="btn-inner--text">Архив курсовых и ВКР</span>
<span class="btn-inner--text">Архив практик и ВКР</span>
</a>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/templates/base_dark.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
<div class="d-flex">
<!-- Media body -->
<div class="ml-3">
<small class="text-sm">Архив курсовых и ВКР</small>
<small class="text-sm">Архив практик и ВКР</small>
</div>
</div>
</a>
Expand Down Expand Up @@ -240,7 +240,7 @@
<div class="d-flex">
<!-- Media body -->
<div class="ml-3">
<small class="text-sm">Архив курсовых и ВКР</small>
<small class="text-sm">Архив практик и ВКР</small>
</div>
</div>
</a>
Expand Down Expand Up @@ -354,7 +354,7 @@ <h6 class="heading mb-3">Студентам</h6>
<li><a href="{{ url_for('scholarships') }}">Стипендии и гранты</a></li>
<li><a href="{{ url_for('summer_school') }}">Летняя школа 2021</a></li>
<li><a href="{{ url_for('summer_school_2022') }}">Летняя школа 2022</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив курсовых и ВКР</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив практик и ВКР</a></li>
<li><a href="{{ url_for('internships_index') }}">Поиск IT-стажировок</a></li>
</ul>
</div>
Expand All @@ -364,7 +364,7 @@ <h6 class="heading mb-3">Сервисы</h6>
<li><a href="{{ url_for('diplomas_index') }}">Темы практик и ВКР</a></li>
<li><a href="{{ url_for('thesis_review_index') }}">Рецензирование практик и ВКР</a></li>
<li><a href="{{ url_for('list_news') }}">Новости</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив курсовых и ВКР</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив практик и ВКР</a></li>
<li><a href="{{ url_for('internships_index') }}">Поиск IT-стажировок</a></li>
<li><a href="{{ url_for('practice_index') }}">Написание практик и ВКР</a></li>
{% if current_user.is_authenticated and current_user.is_staff() %}
Expand Down
8 changes: 4 additions & 4 deletions src/templates/base_dark_footer_white.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
<div class="d-flex">
<!-- Media body -->
<div class="ml-3">
<small class="text-sm">Архив курсовых и ВКР</small>
<small class="text-sm">Архив практик и ВКР</small>
</div>
</div>
</a>
Expand Down Expand Up @@ -240,7 +240,7 @@
<div class="d-flex">
<!-- Media body -->
<div class="ml-3">
<small class="text-sm">Архив курсовых и ВКР</small>
<small class="text-sm">Архив практик и ВКР</small>
</div>
</div>
</a>
Expand Down Expand Up @@ -354,7 +354,7 @@ <h6 class="heading mb-3">Студентам</h6>
<li><a href="{{ url_for('scholarships') }}">Стипендии и гранты</a></li>
<li><a href="{{ url_for('summer_school') }}">Летняя школа 2021</a></li>
<li><a href="{{ url_for('summer_school_2022') }}">Летняя школа 2022</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив курсовых и ВКР</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив практик и ВКР</a></li>
<li><a href="{{ url_for('internships_index') }}">Поиск IT-стажировок</a></li>
</ul>
</div>
Expand All @@ -364,7 +364,7 @@ <h6 class="heading mb-3">Сервисы</h6>
<li><a href="{{ url_for('diplomas_index') }}">Темы практик и ВКР</a></li>
<li><a href="{{ url_for('thesis_review_index') }}">Рецензирование практик и ВКР</a></li>
<li><a href="{{ url_for('list_news') }}">Новости</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив курсовых и ВКР</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив практик и ВКР</a></li>
<li><a href="{{ url_for('internships_index') }}">Поиск IT-стажировок</a></li>
<li><a href="{{ url_for('practice_index') }}">Написание практик и ВКР</a></li>
{% if current_user.is_authenticated and current_user.is_staff() %}
Expand Down
8 changes: 4 additions & 4 deletions src/templates/base_light.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<div class="d-flex">
<!-- Media body -->
<div class="ml-3">
<small class="text-sm">Архив курсовых и ВКР</small>
<small class="text-sm">Архив практик и ВКР</small>
</div>
</div>
</a>
Expand Down Expand Up @@ -228,7 +228,7 @@
<div class="d-flex">
<!-- Media body -->
<div class="ml-3">
<small class="text-sm">Архив курсовых и ВКР</small>
<small class="text-sm">Архив практик и ВКР</small>
</div>
</div>
</a>
Expand Down Expand Up @@ -342,7 +342,7 @@ <h6 class="heading mb-3">Студентам</h6>
<li><a href="{{ url_for('scholarships') }}">Стипендии и гранты</a></li>
<li><a href="{{ url_for('summer_school') }}">Летняя школа 2021</a></li>
<li><a href="{{ url_for('summer_school_2022') }}">Летняя школа 2022</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив курсовых и ВКР</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив практик и ВКР</a></li>
<li><a href="{{ url_for('internships_index') }}">Поиск IT-стажировок</a></li>
</ul>
</div>
Expand All @@ -352,7 +352,7 @@ <h6 class="heading mb-3">Сервисы</h6>
<li><a href="{{ url_for('diplomas_index') }}">Темы практик и ВКР</a></li>
<li><a href="{{ url_for('thesis_review_index') }}">Рецензирование практик и ВКР</a></li>
<li><a href="{{ url_for('list_news') }}">Новости</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив курсовых и ВКР</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив практик и ВКР</a></li>
<li><a href="{{ url_for('internships_index') }}">Поиск IT-стажировок</a></li>
<li><a href="{{ url_for('practice_index') }}">Написание практик и ВКР</a></li>
{% if current_user.is_authenticated and current_user.is_staff() %}
Expand Down
8 changes: 4 additions & 4 deletions src/templates/base_light_footer_white.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<div class="d-flex">
<!-- Media body -->
<div class="ml-3">
<small class="text-sm">Архив курсовых и ВКР</small>
<small class="text-sm">Архив практик и ВКР</small>
</div>
</div>
</a>
Expand Down Expand Up @@ -225,7 +225,7 @@
<div class="d-flex">
<!-- Media body -->
<div class="ml-3">
<small class="text-sm">Архив курсовых и ВКР</small>
<small class="text-sm">Архив практик и ВКР</small>
</div>
</div>
</a>
Expand Down Expand Up @@ -337,7 +337,7 @@ <h6 class="heading mb-3">Студентам</h6>
<li><a href="{{ url_for('scholarships') }}">Стипендии и гранты</a></li>
<li><a href="{{ url_for('summer_school') }}">Летняя школа 2021</a></li>
<li><a href="{{ url_for('summer_school_2022') }}">Летняя школа 2022</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив курсовых и ВКР</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив практик и ВКР</a></li>
<li><a href="{{ url_for('internships_index') }}">Поиск IT-стажировок</a></li>
</ul>
</div>
Expand All @@ -347,7 +347,7 @@ <h6 class="heading mb-3">Сервисы</h6>
<li><a href="{{ url_for('diplomas_index') }}">Темы практик и ВКР</a></li>
<li><a href="{{ url_for('thesis_review_index') }}">Рецензирование практик и ВКР</a></li>
<li><a href="{{ url_for('list_news') }}">Новости</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив курсовых и ВКР</a></li>
<li><a href="{{ url_for('theses_search') }}">Архив практик и ВКР</a></li>
<li><a href="{{ url_for('internships_index') }}">Поиск IT-стажировок</a></li>
<li><a href="{{ url_for('practice_index') }}">Написание практик и ВКР</a></li>
{% if current_user.is_authenticated and current_user.is_staff() %}
Expand Down

0 comments on commit ed691eb

Please sign in to comment.