Bases: django.contrib.admin.options.ModelAdmin
Don’t allow access to individual AccessTime objects.
No need to show the link to page for an individual AccessTime, so no field should link to it, as was set in changelist_view. However, the page can still be accessed, so redirect to change list.
Don’t show links to individual AccessTime change forms from any field. (list_display_links = [] will not works - will default to linking from items in AccessTime column.
Returns the HTML with link to lock user’s change_form to display on the Access Times change list page.
Bases: django.contrib.admin.options.ModelAdmin
Encapsulates all admin options and functionality for a given model.
LockUser may have access to Doors that the staff user cannot admin; this must be accounted for when determining (Javascript) whether to disable “Assign keycard” button or select “Deactivate keycard” because all Doors have been unchecked. In change_form template, will get a set of these Door objects from context, then check the lockuser_set of each to see if the current lockuser has access to it.
Staff should not have the ability to delete LockUsers, only to DEACTIVATE them.
Before deactivating, this checks if the LockUser is permitted doors that the staff user is not. This would mean that the staff user is not allowed to revoke the keycard, and the lock user would remain active.
alias of LockUserForm
The queryset() method in DoorAdmin restricts a staff user’s ability to view/change Doors that they do not have permission for (individual objects and change list). But on the listdisplay and changeform for LockUsers, staff users can still see Doors – and assign them – that they don’t have permission for. So here, we need to to limit the ManyToMany Door field output for the LockUser.
Doors that the staff User is not allowed to administer. In change_form template, will get a set of these Door objects from context, then check the lockuser_set of each to see if the current lockuser has access to it.
If deactivate current keycard was checked (which may have actually happened in clean, if no Doors were selected) need to deactivate current keycard. Doing this here rather than models.py because need to attach request.user to the RFIDkeycard object being deactivated, to record revoker.
Bases: django.forms.models.ModelForm
If no Doors were selected – if user is not permitted to access any door – deactivate associated keycard.
If the user is permitted access to doors that the staff user is not permitted access, make sure lockuser still has access to door staff user is not permitted to manage, since those wouldn’t be on the form. Also, if ‘deactivate current keycard’ was checked in this situation, the keycard should NOT actually be revoked, because of those other doors.
Bases: django.db.models.base.Model
Represents a visit to a space
Bases: django.core.exceptions.ObjectDoesNotExist
Bases: django.core.exceptions.MultipleObjectsReturned
Returns the HTML with link to /lockuser/the_id/ to display on the AccessTime change list page
Bases: django.db.models.base.Model
Doors with RFID locks installed.
Bases: django.core.exceptions.ObjectDoesNotExist
Bases: django.core.exceptions.MultipleObjectsReturned
Bases: django.db.models.base.Model
(Despite the misleading name, LockUsers are not subclassed Users, but subclassed Models.)
Bases: django.core.exceptions.ObjectDoesNotExist
Bases: django.core.exceptions.MultipleObjectsReturned
Returns list of all access times (the actual access_time field, not the objects) for this user, which means that the search should include any other RFID’s this LockUser ever had. In other words, the search is by person, not by RFID.
Returns HTML for displaying list of all keycards (excluding curent, if any). Includes date assigned and date revoked, as well as rfid number.
Returns the HTML with links to /door/the_id/ to display on the LockUser change list page.
Of all RFID’s associated with this LockUser, get the one that’s active, i.e. has not been revoked.
Get the last time this person used the lock. Same story with current RFID vs previous one as in the comment for get_all_access_time().
Including link to all access times (for change form)
Including link to all access times (for change form)
Returns results of get_current_rfid(), but as a nice pretty string. Also display date assigned as well as rfid number on LockUser change form and list display.
Includes the door this access time is associated with (for change list)
Bases: django.db.models.base.Model
For checking whether the current request is for authenticating a keycard or assigning new keycard.
Bases: django.core.exceptions.ObjectDoesNotExist
Bases: django.core.exceptions.MultipleObjectsReturned
Bases: django.db.models.base.Model
Door access represented by a (potentially reusable) RFID keycard (or keyfob or whatever) assigned to a LockUser.
Bases: django.core.exceptions.ObjectDoesNotExist
Bases: django.core.exceptions.MultipleObjectsReturned
Return data in appropriate format for the HighCharts (JavaScript) AccessTime plot. Creates a series for each door.
In addition to checking whether the given rfid is valid for the given door, this checks whether we’re actually trying to assign a new keycard rather than authenticating. If not doing a new keycard scan, create and save an AccessTime.
Verify this is the NewKeycardScan object we initiated, that the rfid is not the same as that of a currently active keycard, and that we haven’t timed out. Then get the rfid from the newly-scanned card.
The new RFIDkeycard object is created upon LockUser save, after change_form form has been submitted.