---
# System prepended metadata

title: Untitled

---


1. show one current record:
    ```
    CurrentRecord.objects.filter(
        environment=Environment.objects.get(name='foo-dev'),
        key=Key.objects.get(name='Ursula'),
    ).select_related()
2. show env current records:
    ```
    CurrentRecord.objects.filter(
        environment=Environment.objects.get(name='foo-dev'),
    ).select_related()
3. show key across all envs:
    ```
    CurrentRecord.objects.filter(
        key=Key.objects.get(name='Ursula'),
    ).select_related()```
4. create/update current record:
`CurrentRecord.objects.update_or_create(environment=rec.environment, key=rec.key, record=rec)`

5. show entry usage:
    ```
    CurrentRecord.objects.filter(record__entry__in=[Entry.objects.get(id=205)])
    CurrentRecord.objects.filter(record__entry__id__in=[205])

6. show record history
    ```Record.objects.filter(
        environment=Environment.objects.get(name='foo-dev'),
        key=Key.objects.get(name='Ursula'),
        approved=True,
        used=True,
    ).select_related()
7. show record candidates:
    ```
    Record.objects.filter(
        environment=Environment.objects.get(name='foo-dev'),
        key=Key.objects.get(name='Ursula'),
        declined=False,
        used=False,
    ).select_related()
8. show env candidates
    ```
    Record.objects.filter(
        environment=Environment.objects.get(name='foo-dev'),
        declined=False,
        used=False,
    ).select_related()
9. show all candidates
    ```
    Record.objects.filter(
        environment=Environment.objects.get(name='foo-dev'),
        declined=False,
        used=False,
    ).select_related()
10. show entry historical usage:
    ```
    Record.objects.filter(entry__in=[Entry.objects.get(id=205)])
    Record.objects.filter(entry__id__in=[205])
    
    * show user permitted records
11. count approvals
 `RecordApproval.objects.filter(record=Record.objects.get(id=123)).count()`
 
12. show approvals
    `RecordApproval.objects.filter(record=Record.objects.get(id=123)).select_related()`
13. approve a candidate
    ```
    RecordApproval(
        record=Record.objects.get(id=123),
        reviewer=user,
    ).save()
14. disapprove a candidate
    ```
    RecordApproval(
        record=Record.objects.get(id=123),
        reviewer=user,
        approved=False,
    ).save()
    
15. show created by a user
16. show approved by a user
17. create env (inluding user owner or group owner, creator != owner, creator not null)
18. de/activate env? (unique na name-active=true?)
19. clone env
20. current record - history
* ficzer - keys
----
21. show envs by owner
22. show records by owner