mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-25 11:01:12 +00:00
commit
984c04a374
8 changed files with 52 additions and 16 deletions
|
@ -187,7 +187,7 @@ def get_following(request, username):
|
|||
return HttpResponseBadRequest()
|
||||
|
||||
user = models.User.objects.get(localname=username)
|
||||
following = models.User.objects.filter(followers=user)
|
||||
following = user.following
|
||||
page = request.GET.get('page')
|
||||
return JsonResponse(activitypub.get_following(user, page, following))
|
||||
|
||||
|
@ -201,8 +201,8 @@ def handle_incoming_follow(activity):
|
|||
# TODO: allow users to manually approve requests
|
||||
try:
|
||||
models.UserRelationship.objects.create(
|
||||
user_subject=to_follow,
|
||||
user_object=user,
|
||||
user_subject=user,
|
||||
user_object=to_follow,
|
||||
status='follow_request',
|
||||
relationship_id=activity['id']
|
||||
)
|
||||
|
|
19
fedireads/migrations/0008_auto_20200224_1504.py
Normal file
19
fedireads/migrations/0008_auto_20200224_1504.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 3.0.3 on 2020-02-24 15:04
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('fedireads', '0007_auto_20200223_0902'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='followers',
|
||||
field=models.ManyToManyField(related_name='following', through='fedireads.UserRelationship', to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
]
|
|
@ -38,7 +38,8 @@ class User(AbstractUser):
|
|||
'self',
|
||||
symmetrical=False,
|
||||
through='UserRelationship',
|
||||
through_fields=('user_subject', 'user_object')
|
||||
through_fields=('user_object', 'user_subject'),
|
||||
related_name='following'
|
||||
)
|
||||
favorites = models.ManyToManyField(
|
||||
'Status',
|
||||
|
|
|
@ -88,8 +88,8 @@ def handle_outgoing_follow(user, to_follow):
|
|||
def handle_outgoing_unfollow(user, to_unfollow):
|
||||
''' someone local wants to follow someone '''
|
||||
relationship = models.UserRelationship.objects.get(
|
||||
user_object=user,
|
||||
user_subject=to_unfollow
|
||||
user_subject=user,
|
||||
user_object=to_unfollow
|
||||
)
|
||||
activity = activitypub.get_unfollow(relationship)
|
||||
errors = broadcast(user, activity, [to_unfollow.inbox])
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<div id="branding"><a href="/">📚FediReads</a></div>
|
||||
<div id="actions">
|
||||
<div id="account">
|
||||
{% if user.is_authenticated %}
|
||||
{% if request.user.is_authenticated %}
|
||||
<form name="logout" action="/logout/" method="post">
|
||||
{% csrf_token %}
|
||||
Welcome, {% include 'snippets/username.html' with user=request.user %}
|
||||
|
|
|
@ -25,12 +25,25 @@
|
|||
{% for follower in user.followers.all %}
|
||||
<div>
|
||||
<a href="{{ follower.actor }}">{{ follower.username }}</a>
|
||||
{% if not request.user in follower.followers.all %}
|
||||
{% if not request.user in follower.followers.all and request.user != follower %}
|
||||
{% include 'snippets/follow_button.html' with user=follower %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2>Following</h2>
|
||||
{% for following in user.following.all %}
|
||||
<div>
|
||||
<a href="{{ following.actor }}">{{ following.username }}</a>
|
||||
{% if not request.user in following.followers.all and request.user != following %}
|
||||
{% include 'snippets/follow_button.html' with user=following %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
|
10
init_db.py
Normal file
10
init_db.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
from fedireads.models import User
|
||||
from fedireads.openlibrary import get_or_create_book
|
||||
|
||||
User.objects.create_user('mouse', 'mouse.reeve@gmail.com', 'password123')
|
||||
User.objects.create_user('rat', 'rat@rat.com', 'ratword')
|
||||
|
||||
User.objects.get(id=1).followers.add(User.objects.get(id=2))
|
||||
|
||||
get_or_create_book('OL1715344W')
|
||||
get_or_create_book('OL102749W')
|
|
@ -21,12 +21,5 @@ fi
|
|||
python manage.py makemigrations fedireads
|
||||
python manage.py migrate
|
||||
|
||||
echo "from fedireads.models import User
|
||||
User.objects.create_user('mouse', 'mouse.reeve@gmail.com', 'password123')" | python manage.py shell
|
||||
echo "from fedireads.models import User
|
||||
User.objects.create_user('rat', 'rat@rat.com', 'ratword')
|
||||
User.objects.get(id=1).followers.add(User.objects.get(id=2))" | python manage.py shell
|
||||
echo "from fedireads.openlibrary import get_or_create_book
|
||||
get_or_create_book('OL1715344W')
|
||||
get_or_create_book('OL102749W')" | python manage.py shell
|
||||
python manage.py shell < init_db.py
|
||||
python manage.py runserver
|
||||
|
|
Loading…
Reference in a new issue