Commit f78dc502 by Awais Committed by Bill DeRusha

Adding comments in forms and mixins.

parent 40c78817
......@@ -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 = {
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment