Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix debug mode for anitya #1867

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ up:
$(MAKE) init-db
@echo "Empty database initialized. Run dump-restore to fill it by production dump."
restart:
$(MAKE) halt && $(call compose-tool) up -d
$(MAKE) halt && $(MAKE) up
halt:
$(call compose-tool) down -t1
bash-web:
Expand Down
2 changes: 1 addition & 1 deletion anitya/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def create(config=None):

# Debug related initialization
# WARNING: For debug and development purpose only
if app.debug: # pragma: no cover
if anitya_config["DEBUG"]: # pragma: no cover
app.register_blueprint(debug.debug_blueprint)

oauth = OAuth(app)
Expand Down
2 changes: 2 additions & 0 deletions anitya/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
SECRET_KEY="changeme please",
# URL to the database
DB_URL="sqlite:////var/tmp/anitya-dev.sqlite",
# DEBUG mode
DEBUG=False,
# List of admins based on their openid
ANITYA_WEB_ADMINS=[],
ADMIN_EMAIL="[email protected]",
Expand Down
10 changes: 0 additions & 10 deletions anitya/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,4 @@
</a>
{% endfor %}
</div>
{% if config["DEBUG"] %}
<div class="d-flex align-itmes-start gap-3">
<a title="user" class="btn btn-outline-primary" role="button" href="{{ url_for('anitya_debug.login', name='user') }}">
<span>User</span>
</a>
<a title="admin" class="btn btn-outline-primary" role="button" href="{{ url_for('anitya_debug.login', name='admin') }}">
<span>Admin</span>
</a>
</div>
{% endif %}
{% endblock %}
14 changes: 14 additions & 0 deletions anitya/templates/login_debug.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends "master.html" %}

{% block title %}Login · Anitya{% endblock %}

{% block body %}
<div class="d-flex align-itmes-start gap-3">
<a title="user" class="btn btn-outline-primary" role="button" href="{{ url_for('anitya_debug.login', name='user') }}">
<span>User</span>
</a>
<a title="admin" class="btn btn-outline-primary" role="button" href="{{ url_for('anitya_debug.login', name='admin') }}">
<span>Admin</span>
</a>
</div>
{% endblock %}
1 change: 1 addition & 0 deletions anitya/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def test_full_config_file(self, mock_exists, mock_log):
"SECRET_KEY": "very_secret",
"PERMANENT_SESSION_LIFETIME": timedelta(seconds=3600),
"DB_URL": "sqlite:////var/tmp/anitya-dev.sqlite",
"DEBUG": False,
"ANITYA_WEB_ADMINS": ["http://pingou.id.fedoraproject.org"],
"ADMIN_EMAIL": "[email protected]",
"ANITYA_LOG_CONFIG": {
Expand Down
2 changes: 2 additions & 0 deletions anitya/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def login():
next_url = "/"

flask.session["next_url"] = next_url
if anitya_config["DEBUG"]: # pragma: no cover
return flask.render_template("login_debug.html")
return flask.render_template("login.html")


Expand Down
3 changes: 3 additions & 0 deletions files/anitya.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ permanent_session_lifetime = 3600
# URL to the database
db_url = "sqlite:////var/tmp/anitya-dev.sqlite"

# Anitya DEBUG mode
debug = false

# List of web administrators. The values should be the value of the "id" column
# for the user in the "users" table of the database. They need to log in before
# this record is created. An example value would be
Expand Down
Loading