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
f78dc502
Commit
f78dc502
authored
Mar 06, 2017
by
Awais
Committed by
Bill DeRusha
Mar 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding comments in forms and mixins.
parent
40c78817
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
course_discovery/apps/publisher/forms.py
+3
-0
course_discovery/apps/publisher/mixins.py
+13
-0
No files found.
course_discovery/apps/publisher/forms.py
View file @
f78dc502
...
...
@@ -143,6 +143,7 @@ class CustomCourseForm(CourseForm):
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
# In case of edit mode pre-populate the drop-downs
user
=
kwargs
.
pop
(
'user'
,
None
)
edit_mode
=
kwargs
.
pop
(
'edit_mode'
,
None
)
organization
=
kwargs
.
pop
(
'organization'
,
None
)
...
...
@@ -287,6 +288,7 @@ class SeatForm(BaseCourseForm):
exclude
=
(
'currency'
,
'changed_by'
,)
def
save
(
self
,
commit
=
True
,
course_run
=
None
,
changed_by
=
None
):
# pylint: disable=arguments-differ
# When seat is save make sure its prices and others fields updated accordingly.
seat
=
super
(
SeatForm
,
self
)
.
save
(
commit
=
False
)
if
seat
.
type
in
[
Seat
.
HONOR
,
Seat
.
AUDIT
]:
seat
.
price
=
0.00
...
...
@@ -350,6 +352,7 @@ class CustomSeatForm(SeatForm):
class
BaseUserAdminForm
(
forms
.
ModelForm
):
"""This form will be use for type ahead search in django-admin."""
class
Meta
:
fields
=
'__all__'
widgets
=
{
...
...
course_discovery/apps/publisher/mixins.py
View file @
f78dc502
...
...
@@ -10,6 +10,9 @@ from course_discovery.apps.publisher.utils import is_internal_user, is_publisher
class
PublisherPermissionMixin
(
object
):
"""
This class will check the logged in user permission for a given course object.
"""
permission
=
None
...
...
@@ -25,6 +28,16 @@ class PublisherPermissionMixin(object):
return
None
def
has_user_access
(
self
,
user
):
""" check has the access on course.
If user is publisher admin or internal user return True otherwise
check user has the organization permission on the given course.
Arguments:
user (User): User object
Returns:
Boolean
"""
course
=
self
.
get_course
()
return
(
check_roles_access
(
user
)
or
...
...
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