FAQ
| This is a
LIVE
service |
Changelog
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Lookup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Information Services
DevOps
Django Libraries
Lookup
Commits
cf4d60f6
Commit
cf4d60f6
authored
10 years ago
by
Dr Abraham Martin
Browse files
Options
Downloads
Patches
Plain Diff
README changes
parent
2467a536
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+23
-6
23 additions, 6 deletions
README.md
with
23 additions
and
6 deletions
README.md
+
23
−
6
View file @
cf4d60f6
...
...
@@ -99,14 +99,31 @@ group.
The module also provides some useful functions to use in your app that do all the calls to the lookup service needed.
get_group_ids_of_a_user_in_lookup(user): Returns the list of group ids of a user
*
get_group_ids_of_a_user_in_lookup(user)
*
: Returns the list of group ids of a user
user_in_groups(user, lookup_groups): Check in the lookup webservice if the user is member of any of the groups in the
*
user_in_groups(user, lookup_groups)
*
: Check in the lookup webservice if the user is member of any of the groups in the
LookupGroup list passed by parameter. Returns True if the user is in any of the groups or False otherwise
def get_institutions(user=None): Returns the list of institutions using the lookup ucam service. The institutions of
*
def get_institutions(user=None)
*
: Returns the list of institutions using the lookup ucam service. The institutions of
the user passed by parameters will be shown first in the list returned
get_institution_name_by_id(institution_id, all_institutions=None): Returns the name of an institution by the id passed.
If all_institutions is passed (the result from get_institutions) then the search is done locally using this list instead
of a lookup call.
*get_institution_name_by_id(institution_id, all_institutions=None)*
: Returns the name of an institution by the id
passed. If all_institutions is passed (the result from get_institutions) then the search is done locally using this
list instead of a lookup call.
The last two methods can be used to add institutions to a model and show the name instead of the code in the admin
interface
```
python
class
MyModelAdmin
(
ModelAdmin
):
all_institutions
=
get_institutions
()
model
=
MyModel
list_display
=
(
'
institution
'
,
)
list_filter
=
(
'
institution_id
'
,
)
def
institution
(
self
,
obj
):
return
get_institution_name_by_id
(
obj
.
institution_id
,
self
.
all_institutions
)
institution
.
admin_order_field
=
'
institution_id
'
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment