This repository has been archived by the owner on Sep 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Add AJAX functions for following/unfollowing users #9
Open
TJBANEY
wants to merge
14
commits into
SriNandan33:master
Choose a base branch
from
TJBANEY:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
023062e
Add AJAX methods to follow and unfollow users
TJBANEY 5cb1d39
Add AJAX functions for follow/unfollow
TJBANEY 4f54238
Create static directory and move follow_unfollow js into it
TJBANEY a0e06bf
Convert follow/unfollow button into snippets for reusability
TJBANEY 3c610ce
Remove inline javascript form base.html for follow/unfollow
TJBANEY 5669a9e
Clean up import structure for PEP-8 style guide
TJBANEY e937d85
Replace hardcoded follow/unfollow links in user popup with template s…
TJBANEY e1c39e4
Move inline JS in base template into its own JS file
TJBANEY 87e66bb
Update follow/unfollow snippets
TJBANEY f417c82
tig
TJBANEY 3cd6b21
Add hover.js script to base template
TJBANEY 1226a6d
Remove console statements
TJBANEY 211807f
Fix .gitignore
TJBANEY b9d1802
.
TJBANEY File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,19 @@ <h1>User: {{ user.username }}</h1> | |
{% if user.last_seen %}<p>Last seen on: {{ moment(user.last_seen).format('LLL') }}</p>{% endif %} | ||
<p>{{ user.followers.count()}} followers, {{ user.followed.count()}} following.</p> | ||
{% if user == current_user %} | ||
<p><a href="{{ url_for('core.edit_profile')}}">Edit Profile</a></p> | ||
<p> | ||
<a href="{{ url_for('core.edit_profile')}}"> | ||
Edit Profile | ||
</a> | ||
</p> | ||
{% elif current_user.is_following(user) %} | ||
<p><a href="{{ url_for('core.unfollow', username=user.username)}}">Unfollow</a></p> | ||
<div class="follow-link"> | ||
<p onclick="unFollowUser()">Unfollow</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is also good to go 👍 |
||
</div> | ||
{% else %} | ||
<p><a href="{{ url_for('core.follow', username=user.username)}}">Follow</a></p> | ||
<div class="follow-link"> | ||
<p onclick="followUser()">Follow</p> | ||
</div> | ||
{% endif %} | ||
</td> | ||
</tr> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user object is only available in user.html, it is not available in base.html. It will work for /user/ endpoint, but it will not work for other endpoints, you may get
jinja2.exceptions.UndefinedError
, please check.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest moving follow, unfollow links to some reusable html template and use it everywhere, and move this javascript code to the new template created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @SriNandan33 I made those follow/unfollow buttons snippets, and migrated the inline javascript used for following/unfollowing into a static directory