roundabout,
created on Thursday, 4 January 2024, 20:32:43 (1704400363),
received on Wednesday, 31 July 2024, 06:54:40 (1722408880)
Author identity: vlad <vlad.muntoiu@gmail.com>
fa25224d77b0653e0c36e686ac151651f051e2df
app.py
@@ -127,7 +127,7 @@ repositories = flask.Blueprint("repository", __name__, template_folder="template
def default(): username = flask.session.get("username") userObject = User.query.filter_by(username=username)userObject = User.query.filter_by(username=username).first()return { "loggedInUser": username,
@@ -301,17 +301,18 @@ def userProfile(username):
user = User.query.filter_by(username=username).first() repos = Repo.query.filter_by(ownerName=username, visibility=2) return flask.render_template("user-profile.html", user=user, repos=repos, relationship=oldRelationship) elif request.query.get("action") == "follow":elif flask.request.args.get("action") == "follow":if oldRelationship: db.session.delete(oldRelationship) else: relationship = UserFollow( User.query.filter_by(username=db.session.get("username")),User.query.filter_by(username=username)flask.session.get("username"), username) db.session.add(relationship) db.session.commit() return flask.redirect("?", code=303)@app.route("/<username>/<repository>/")
models.py
@@ -226,9 +226,9 @@ with app.app_context():
follower = db.relationship("User", back_populates="follows", foreign_keys=[followedUsername]) followed = db.relationship("User", back_populates="followers", foreign_keys=[followerUsername]) def __init__(self, follower, followed):self.followerUsername = follower.usernameself.followedUsername = followed.usernamedef __init__(self, followerUsername, followedUsername): self.followerUsername = followerUsername self.followedUsername = followedUsernameclass Notification(db.Model):
templates/user-profile.html
@@ -38,8 +38,8 @@
{% if user.showMail %} <li><a href="mailto:{{ user.email }}"><x-hbox><iconify-icon icon="mdi:email"></iconify-icon>{{ user.email }}</x-hbox></a></li> {% endif %} {% if loggedInUser != user.username %}<li><form action="?action=follow">{% if loggedInUser != user.username and loggedInUser %} <li><form action="?action=follow" method="POST"><button type="submit"> {% if relationship %}Unfollow{% else %}Follow{% endif %} </button>