The CUED People database¶
cuedmembers application contains models and logic to maintain a
shadow copy of a list of CUED members. It augments the builtin
django.contrib.auth.User model with information about a member of
CUED. This includes:
- The full list of “first names”;
- Their research group and division (if any); and
- Whether they are a current member of CUED.
An extension of the standard Django User to indicate that a particular user is a member of the Department.
There is a one-to-one mapping of Users to Members however not every User is necessarily a Member.
While there is nothing stopping you adding a foreign-key to a Member in models, its better to add a foreign-key to a User. That way you app’s models are decoupled from relying on the CUED membership database and may be of wider user.
The “Surname” and “Preferred name” fields from the Department are mapped through to the associated User’s
first_name. The “First names” provided by the Department are stored in this model.
An “active” member is currently present at CUED.
Information in this model is expected to be provided by the Department. See http://www-itsd.eng.cam.ac.uk/datadownloads/support/div_people.html for some discussion of what the fields mean.
Note that is_active is the primary means by which one should judge if a Member is currently a member of the Department.
This model does not include role/course, host/supervisor, room number or phone number. The “arrived” flag is folded into the is_active field.
django.contrib.auth.models.Userassociated with this Member.
A string containing the first names for the member supplied by the Department. Although it is tempting to use a space as a separator for these, that way danger lies!
Members are not usually deleted from the database. Instead they become “active” or “inactive”. This is to allow for the same person to be considered as the same person if they leave CUED and then subsequently return.
This member’s CRSid. The CRSid is the username of the associated user.
This property merely returns the
usernameof the associated User.
A specialised Manager for
A query-set of active users.
A query-set of inactive users.
Retrieve or create a new member from a crsid. If a corresponding user does not exist, it is created. The newly created user has set_unusable_password() called on it and is added to the database.
The first_name, last_name and email entries in defaults are set on the corresponding user and any other values are set on the member.
See the update_or_create() documentation for discussion of the defaults parameter.
CUED members who are active are a member of a group. Membership of this group is automatic for those members who have
Truewhen imported from CSV via
The group membership is not automatically updated when
save()is called on the
models.Membermodel. This is because only advanced users who know what they’re doing should be fiddling with the database model directly!
By default this group is called “CUED Members” but the name may be overridden by setting the
The Department is structure into Divisions which comprise separate Research
cuedmembers app ships with a fixture which is automatically
loaded into the database at migrate-time which contains the current Divisions
and Research Groups.
A division within CUED. The primary key for a division is actually its letter, A-F.
The Divisional ID letter, A-F.
A human-readable name for the Division.
- String giving the name of the group created or returned by
Synchronising membership data via CSV files¶
importcuedmembers management command is used to synchronise the
membership database with an authoritative source.
The Department provide CSV dumps of CUED membership. See http://www-itsd.eng.cam.ac.uk/datadownloads/support/div_people.html for more details. This command allows the ingestion of a CSV file in the format outlined at that page into the database.
Members listed in the CSV file are created if they don’t exist. Their personal details, such as first name, surname, etc. are updated from the CSV. A previously active member who does not appear in the CSV file is marked inactive. Similarly, a previously inactive member who appears in the CSV file is marked active.
By default, an email address of
<crsid>@cam.ac.uk is used for each member.
This can be configured through the
This command can take either a path to a CSV file on the local system or a http or https URL to a CSV file located on a remote server.