Skip to content

Remove legacy Jinja2 view functions#920

Open
Marvinrose wants to merge 1 commit intofedora-infra:swatantryafrom
Marvinrose:cleanup/remove-legacy-view-functions
Open

Remove legacy Jinja2 view functions#920
Marvinrose wants to merge 1 commit intofedora-infra:swatantryafrom
Marvinrose:cleanup/remove-legacy-view-functions

Conversation

@Marvinrose
Copy link
Copy Markdown

Part of #904

Remove legacy view functions that render Jinja2 templates

Directory: tahrir/views/

Views that render legacy templates: index, about, user, diff, badge, badge_full, leaderboard, report, explore, explore_badges, admin, builder, thingiview, assertion_widget, tags

@gridhead gridhead self-requested a review April 2, 2026 05:48
@gridhead gridhead self-assigned this Apr 2, 2026
@gridhead gridhead added cle Community Linux Engineering स्वातंत्र्य Fedora Badges Revamp Project labels Apr 2, 2026
@gridhead gridhead linked an issue Apr 2, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Member

@gridhead gridhead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Marvinrose, apart from addressing the changes that I have suggested to you, please sign your commit activities and specify the AI tooling used in making this pull request happen.

Comment on lines +96 to +133


@bp.route("/invitations/<claim_id>/claim")
def invitation_claim(claim_id):
"""Action that awards a person a badge after scanning a qrcode."""
claim = g.tahrirdb.get_invitation(claim_id)
if claim.expires_on < datetime.now():
return abort(410, "That invitation is expired.")

email = g.oidc_user.email
if not email:
return redirect(f"{url_for('oidc_auth.login')}?next={request.url}")

if g.tahrirdb.assertion_exists(claim.badge_id, g.oidc_user.person.email):
flash(f"You already have {claim.badge_id} badge")
else:
g.tahrirdb.add_assertion(
claim.badge_id, g.oidc_user.person.email, datetime.now(timezone.utc)
)
flash(f"You have earned {claim.badge_id} badge. Your rank will be updated shortly.")

return redirect(url_for("tahrir.home"))


@bp.route("/invitations/<claim_id>/qrcode")
def invitation_qrcode(claim_id):
"""Returns a raw dummy qrcode through to the user."""
claim = g.tahrirdb.get_invitation(claim_id)
if claim.expires_on < datetime.now():
return abort(410, "That invitation is expired.")

target = url_for("tahrir.invitation_claim", claim_id=claim_id, _external=True)
img = qrcode_module.make(target)
bytestream = BytesIO()
img.save(bytestream)
return bytestream.getvalue(), {
"content-type": "image/png",
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you do this?

"date": objc.created_on.timestamp(),
}
rslt.append({"id": item, **base, **data["badges"][item]})
else:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was the else clause removed here?

"about.html",
content=load_docs("about"),
)
from . import blueprint as bp # noqa: F401
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure there is not a better way of handling this?

@@ -237,21 +48,3 @@ def add_tag(request):
g.tahrirdb.session.flush()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The add_tag bug seems like it is going to come back and bite later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cle Community Linux Engineering स्वातंत्र्य Fedora Badges Revamp Project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove legacy Jinja2 frontend and associated dead code

2 participants