Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
groups : user groups¶
We assume that you have read the end-user documentation page in The groups plugin.
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_book.projects.chatter.startup import *
Usage¶
When you install this plugin, you will probably add a panel “Memberships”
(MembershipsByUser) to the detail layout of your
lino.modlib.users.UserDetail.
This plugin doesn’t create its own top-level menu but adds its menu commands to
the same menu as lino.modlib.system.
>>> dd.plugins.groups.menu_group
'system'
>>> print(dd.plugins.groups.verbose_name)
Groups
>>> show_menu_path(groups.Groups)
Configure --> Site --> Groups
Plugin settings¶
Demo data¶
>>> rt.login("robin").show(users.Users)
========== ===================== ============ =========== ===================
Username User type First name Last name e-mail address
---------- --------------------- ------------ ----------- -------------------
andy 100 (User) Andreas Anderson andy@example.com
bert 100 (User) Albert Bernstein bert@example.com
chloe 100 (User) Chloe Cleoment chloe@example.com
robin 900 (Administrator) Robin Rood demo@example.com
========== ===================== ============ =========== ===================
The list of groups varies depending on who is watching. Robin as a SiteAdmin sees all groups:
>>> rt.login("robin").show(groups.Groups)
=========== ==========================================
Reference Group
----------- ------------------------------------------
`Hitchhiker's Guide to the Galaxy <…>`__
`Star Trek <…>`__
`Harry Potter <…>`__
=========== ==========================================
Andy does not see the Star Trek group because it’s private and he’s not a member.
>>> rt.login("andy").show(groups.MyGroups)
=========== ================================== ========= ==========
Reference Designation Private Workflow
----------- ---------------------------------- --------- ----------
Hitchhiker's Guide to the Galaxy No
Harry Potter No
=========== ================================== ========= ==========
Anonymous doesn’t see any groups:
>>> rt.login("").show(groups.MyGroups)
Traceback (most recent call last):
...
django.core.exceptions.PermissionDenied: Not permitted for anonymous
>>> andy = users.User.objects.get(username="andy")
>>> ses = rt.login("robin")
>>> ses.show(groups.MembershipsByUser, master_instance=andy)
================================== ========
Group Remark
---------------------------------- --------
Hitchhiker's Guide to the Galaxy
Harry Potter
================================== ========
>>> rt.login("andy").show(groups.MembershipsByUser, master_instance=andy)
================================== ========
Group Remark
---------------------------------- --------
Hitchhiker's Guide to the Galaxy
Harry Potter
================================== ========
>>> trek = groups.Group.objects.get(name="Star Trek")
>>> ses.show(groups.MembershipsByGroup, master_instance=trek)
================ ======== ==================================== ==========
User Remark Mail recipient Workflow
---------------- -------- ------------------------------------ ----------
Chloe Cleoment Chloe Cleoment <chloe@example.com>
Robin Rood Robin Rood <demo@example.com>
================ ======== ==================================== ==========
The display mode for memberships¶
The MembershipsByGroup and MembershipsByUser tables should use
summary mode in a narrow context (less than 80 chars available width) and grid
mode when the user opens the panel in its own window.
>>> pprint(groups.Memberships.default_display_modes)
{None: 'grid', 70: 'summary'}
>>> groups.Memberships.get_display_mode(80)
'grid'
>>> groups.Memberships.get_display_mode(60)
'summary'
Class reference¶
- class lino_xl.lib.groups.Group¶
Django model representing a user group.
- ref¶
The reference. An optional alphanumeric identifier that, unlike the primary key, is editable.
See
lino.mixins.ref.StructuredReferrable.ref
- name¶
The designation in different languages.
- user¶
The owner of the group
- private¶
Whether this group is considered private. See Visibility of comments.
- class lino_xl.lib.groups.Membership¶
Django model representing a user membership.
- user¶
- group¶
- remark¶
- class lino_xl.lib.groups.Groups¶
Shows all groups.