Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
course-discovery
Commits
06995832
Commit
06995832
authored
Mar 26, 2016
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added row-level permissions to Catalog model
ECOM-3973
parent
87708bf6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
2 deletions
+35
-2
course_discovery/apps/catalogs/admin.py
+2
-1
course_discovery/apps/catalogs/migrations/0002_auto_20160327_2101.py
+18
-0
course_discovery/apps/catalogs/models.py
+6
-0
course_discovery/apps/core/models.py
+2
-1
course_discovery/settings/base.py
+6
-0
requirements/base.txt
+1
-0
No files found.
course_discovery/apps/catalogs/admin.py
View file @
06995832
from
django.contrib
import
admin
from
guardian.admin
import
GuardedModelAdmin
from
course_discovery.apps.catalogs.models
import
Catalog
@admin.register
(
Catalog
)
class
CatalogAdmin
(
admin
.
ModelAdmin
):
class
CatalogAdmin
(
Guarded
ModelAdmin
):
list_display
=
(
'name'
,)
readonly_fields
=
(
'created'
,
'modified'
,)
...
...
course_discovery/apps/catalogs/migrations/0002_auto_20160327_2101.py
0 → 100644
View file @
06995832
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'catalogs'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'catalog'
,
options
=
{
'ordering'
:
(
'-modified'
,
'-created'
),
'permissions'
:
((
'view_catalog'
,
'Can view catalog'
),),
'get_latest_by'
:
'modified'
},
),
]
course_discovery/apps/catalogs/models.py
View file @
06995832
...
...
@@ -47,3 +47,9 @@ class Catalog(TimeStampedModel):
contains
[
result
.
get_stored_fields
()[
'key'
]]
=
True
return
contains
class
Meta
(
TimeStampedModel
.
Meta
):
abstract
=
False
permissions
=
(
(
'view_catalog'
,
'Can view catalog'
),
)
course_discovery/apps/core/models.py
View file @
06995832
...
...
@@ -3,9 +3,10 @@
from
django.contrib.auth.models
import
AbstractUser
from
django.db
import
models
from
django.utils.translation
import
ugettext_lazy
as
_
from
guardian.mixins
import
GuardianUserMixin
class
User
(
AbstractUser
):
class
User
(
GuardianUserMixin
,
AbstractUser
):
"""Custom user model for use with OpenID Connect."""
full_name
=
models
.
CharField
(
_
(
'Full Name'
),
max_length
=
255
,
blank
=
True
,
null
=
True
)
...
...
course_discovery/settings/base.py
View file @
06995832
...
...
@@ -36,6 +36,7 @@ THIRD_PARTY_APPS = (
'sortedm2m'
,
'simple_history'
,
'haystack'
,
'guardian'
,
)
PROJECT_APPS
=
(
...
...
@@ -166,8 +167,13 @@ AUTH_USER_MODEL = 'core.User'
AUTHENTICATION_BACKENDS
=
(
'auth_backends.backends.EdXOpenIdConnect'
,
'django.contrib.auth.backends.ModelBackend'
,
'guardian.backends.ObjectPermissionBackend'
,
)
# Guardian settings
ANONYMOUS_USER_NAME
=
None
# Do not allow anonymous user access
GUARDIAN_MONKEY_PATCH
=
False
# Use the mixin on the User model instead of monkey-patching.
ENABLE_AUTO_AUTH
=
False
AUTO_AUTH_USERNAME_PREFIX
=
'auto_auth_'
...
...
requirements/base.txt
View file @
06995832
django==1.8.7
django-extensions==1.5.9
django-guardian==1.4.2
django-haystack==2.4.1
django-simple-history==1.8.1
django-sortedm2m==1.1.1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment