add rules package, create rule for is_job_poster
This commit is contained in:
parent
58c739c4e6
commit
95d2f9c3d1
3 changed files with 16 additions and 0 deletions
|
@ -48,6 +48,9 @@ INSTALLED_APPS += [
|
||||||
# before 'django.contrib.admin' app
|
# before 'django.contrib.admin' app
|
||||||
'dal',
|
'dal',
|
||||||
'dal_select2',
|
'dal_select2',
|
||||||
|
|
||||||
|
# for authorization
|
||||||
|
'rules',
|
||||||
]
|
]
|
||||||
|
|
||||||
# Our apps
|
# Our apps
|
||||||
|
@ -115,6 +118,10 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
AUTHENTICATION_BACKENDS = (
|
||||||
|
'rules.permissions.ObjectPermissionBackend',
|
||||||
|
'django.contrib.auth.backends.ModelBackend',
|
||||||
|
)
|
||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/2.1/topics/i18n/
|
# https://docs.djangoproject.com/en/2.1/topics/i18n/
|
||||||
|
|
8
jobs/rules.py
Normal file
8
jobs/rules.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import rules
|
||||||
|
|
||||||
|
@rules.predicate
|
||||||
|
def is_job_poster(user, job):
|
||||||
|
return job.posted_by == user
|
||||||
|
|
||||||
|
|
||||||
|
rules.add_perm('jobs.change_job', is_job_poster)
|
|
@ -1,3 +1,4 @@
|
||||||
Django==2.1.2
|
Django==2.1.2
|
||||||
django-crispy-forms==1.7.2
|
django-crispy-forms==1.7.2
|
||||||
git+https://github.com/yourlabs/django-autocomplete-light.git#egg=django-autocomplete-light
|
git+https://github.com/yourlabs/django-autocomplete-light.git#egg=django-autocomplete-light
|
||||||
|
rules==2.0
|
||||||
|
|
Loading…
Reference in a new issue