friends in Lino Seggi¶
The lino_xl.lib.friends plugin is used in Lino Seggi to manage friends. This plugin adds functionality for managing
friendships between users. A friendship is represented as a friend request, which gets issued by one user to another user,
who must confirm the friendship before it becomes active. A confirmed request is visible by both users in their list of “My friends”.
The plugin creates a single database model: Request(UserAuthored, Modified) Its objective is to relate two different users to each other into a friendship. The model uses 3 actions to decide what happens when a user responds to a request. The receiving user can either accept the request, which would make them two users friends or refuse the request which basically deletes the request. The user that sends the friend request to another user can also cancel it, in case they made a mistake or changed their mind
It defines several tables: Requests, SentRequests, IncomingRequests, MyFriends, Friends, FriendsByUser
Requests (dd.Table)
Lists all friendship requests made on the site.
SentRequests (My, Requests)
Lists all requests sent out by the current user.
IncomingRequests (Requests)
Lists all requests received by the current user.
Friends (ListedUsers)
A base table used to configure the detail layout when viewing a user’s friends.
MyFriends (Friends)
Lists all established friendships for the current user.
FriendsByUser (Friends)
Displays the friends of a specific user.
It defines several actions: RecipientAction, AcceptRequest, RefuseRequest, CancelRequest
RecipientAction (dd.Action)
A base action configured for multi-row selection (select_rows = True), hidden from the main toolbar (show_in_toolbar = False), and exposed in the workflow menu (show_in_workflow = True).
It verifies user authorization and ensures the request hasn’t already been handled before executing via run_from_ui.
AcceptRequest (RecipientAction)
Sets target_value = True to accept incoming requests.
RefuseRequest (RecipientAction)
Sets target_value = False to decline incoming requests.
CancelRequest (RecipientAction)
Validates that the current user is the original sender, then deletes the request record.
The plugin creates a single database model: Request(UserAuthored, Modified) Its objective is to relate two different users to each other into a friendship. The model uses 3 actions to decide what happens when a user responds to a request. The receiving user can either accept the request, which would make them two users friends or refuse the request which basically deletes the request. The user that sends the friend request to another user can also cancel it, in case they made a mistake or changed their mind
It defines several tables: Requests, SentRequests, IncomingRequests, MyFriends, Friends, FriendsByUser
Requests (dd.Table)
Lists all friendship requests made on the site.
SentRequests (My, Requests)
Lists all requests sent out by the current user.
IncomingRequests (Requests)
Lists all requests received by the current user.
Friends (ListedUsers)
A base table used to configure the detail layout when viewing a user’s friends.
MyFriends (Friends)
Lists all established friendships for the current user.
FriendsByUser (Friends)
Displays the friends of a specific user.
It defines several actions: RecipientAction, AcceptRequest, RefuseRequest, CancelRequest
RecipientAction (dd.Action)
A base action configured for multi-row selection (select_rows = True), hidden from the main toolbar (show_in_toolbar = False), and exposed in the workflow menu (show_in_workflow = True).
It verifies user authorization and ensures the request hasn’t already been handled before executing via run_from_ui.
AcceptRequest (RecipientAction)
Sets target_value = True to accept incoming requests.
RefuseRequest (RecipientAction)
Sets target_value = False to decline incoming requests.
CancelRequest (RecipientAction)
Validates that the current user is the original sender, then deletes the request record.
This page contains code snippets (lines starting with >>>), which are
being tested during our development workflow. The following
snippet initializes the demo project used throughout this page.
>>> from lino_seggi.projects.seggi1.startup import *
My friends¶
This table has a customized get_request_queryset() method. It shows all
the users for which there is an accepted friend request. The friend request has
either been sent by me (and accepted by the other user), or it was sent to me
from another user (and I accepted it).
>>> ar = rt.login("alfons.ausdemwald")
>>> ar.show(friends.MyFriends)
==================== =========== ============ ================== ==========
Username Last name First name e-mail address Language
-------------------- ----------- ------------ ------------------ ----------
germaine.gernegroß Gernegroß Germaine en
hans.altenberg Altenberg Hans en
irene.ingels Ingels Irene en
jacqueline.jacobs Jacobs Jacqueline en
robin Rood Robin demo@example.com en
ulrike.charlier Charlier Ulrike en
==================== =========== ============ ================== ==========
Sent friend requests¶
>>> ar.show(friends.SentRequests)
======================== ==========
Recipient Workflow
------------------------ ----------
Hildegard Hilgers (23) [Cancel]
Johann Johnen (28) [Cancel]
======================== ==========
Incoming friend requests¶
>>> ar.show(friends.IncomingRequests)
==================== ===================
Sender Workflow
-------------------- -------------------
Daniel Emonts (18) [Accept] [Refuse]
Jérémy Jansen (26) [Accept] [Refuse]
==================== ===================
Friends¶
>>> ar.show(friends.Friends)
============================ ===================== ==========
Username User type Language
---------------------------- --------------------- ----------
alfons.ausdemwald 100 (User) en
andreas.arens 100 (User) en
annette.arens 100 (User) en
bernd.evertz 100 (User) en
berta.ernst 100 (User) en
charlotte.collard 100 (User) en
d.dobbelstein-demeulenaere 100 (User) en
daniel.dericum 100 (User) en
daniel.emonts 100 (User) en
dorothée.demeulenaere 100 (User) en
dorothée.dobbelstein 100 (User) en
eberhart.evers 100 (User) en
edgar.engels 100 (User) en
germaine.gernegroß 100 (User) en
gregory.groteclaes 100 (User) en
guido.lambertz 100 (User) en
hans.altenberg 100 (User) en
henri.hilgers 100 (User) en
hildegard.hilgers 100 (User) en
irene.ingels 100 (User) en
jacqueline.jacobs 100 (User) en
jan.jousten 100 (User) en
johann.johnen 100 (User) en
josef.jonas 100 (User) en
josefine.leffin 100 (User) en
jérémy.jansen 100 (User) en
karl.kaivers 100 (User) en
laura.laschet 100 (User) en
laurent.bastiaensen 100 (User) en
line.lazarus 100 (User) en
luc.faymonville 100 (User) en
marc.chantraine 100 (User) en
marc.malmendier 100 (User) en
marie-louise.meier 100 (User) en
melissa.meessen 100 (User) en
michael.mießen 100 (User) en
rando 900 (Administrator) et
robin 900 (Administrator) en
ulrike.charlier 100 (User) en
============================ ===================== ==========
Friends by user¶
>>> user = users.User.objects.get(first_name='Annette')
>>> ar.show(friends.FriendsByUser, user)
============= ============
Last name First name
------------- ------------
Gernegroß Germaine
Altenberg Hans
Laschet Laura
Faymonville Luc
============= ============