openedx.core.djangoapps.django_comment_common package#
Subpackages#
- openedx.core.djangoapps.django_comment_common.comment_client package
- Submodules
- openedx.core.djangoapps.django_comment_common.comment_client.comment module
- openedx.core.djangoapps.django_comment_common.comment_client.comment_client module
- openedx.core.djangoapps.django_comment_common.comment_client.commentable module
- openedx.core.djangoapps.django_comment_common.comment_client.course module
- openedx.core.djangoapps.django_comment_common.comment_client.models module
ModelModel.DEFAULT_ACTIONSModel.DEFAULT_ACTIONS_WITHOUT_IDModel.DEFAULT_ACTIONS_WITH_IDModel.accessible_fieldsModel.after_save()Model.base_urlModel.before_save()Model.default_retrieve_paramsModel.delete()Model.find()Model.get()Model.handle_create()Model.handle_create_comment()Model.handle_create_thread()Model.handle_update()Model.handle_update_comment()Model.handle_update_thread()Model.handle_update_user()Model.initializable_attributes()Model.initializable_fieldsModel.items()Model.metric_tag_fieldsModel.retrieve()Model.save()Model.to_dict()Model.updatable_attributes()Model.updatable_fieldsModel.url()Model.url_with_id()Model.url_without_id()
- openedx.core.djangoapps.django_comment_common.comment_client.settings module
- openedx.core.djangoapps.django_comment_common.comment_client.subscriptions module
- openedx.core.djangoapps.django_comment_common.comment_client.thread module
- openedx.core.djangoapps.django_comment_common.comment_client.user module
UserUser.accessible_fieldsUser.active_threads()User.base_urlUser.default_retrieve_paramsUser.follow()User.from_django_user()User.initializable_fieldsUser.metric_tag_fieldsUser.read()User.replace_username()User.retire()User.subscribed_threads()User.typeUser.unfollow()User.unvote()User.updatable_fieldsUser.vote()
- openedx.core.djangoapps.django_comment_common.comment_client.utils module
- Module contents
Submodules#
openedx.core.djangoapps.django_comment_common.models module#
- class openedx.core.djangoapps.django_comment_common.models.CourseDiscussionSettings(*args, **kwargs)#
Bases:
ModelSettings for course discussions
- ASSIGNMENT_TYPE_CHOICES = (('none', 'None'), ('cohort', 'Cohort'), ('enrollment_track', 'Enrollment Track'))#
- COHORT = 'cohort'#
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- ENROLLMENT_TRACK = 'enrollment_track'#
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- NONE = 'none'#
- always_divide_inline_discussions#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- course_id#
DO NOT REUSE THIS CLASS. Provided for backwards compatibility only!
A placeholder class that provides a way to set the attribute on the model.
- discussions_id_map#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property divided_discussions#
Jsonify the divided_discussions
- division_scheme#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod get(course_key)#
Get and/or create settings
- get_division_scheme_display(*, field=<django.db.models.fields.CharField: division_scheme>)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- reported_content_email_notifications#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- update(validated_data: dict)#
Set discussion settings for a course
- Returns:
A CourseDiscussionSettings object
- class openedx.core.djangoapps.django_comment_common.models.DiscussionsIdMapping(*args, **kwargs)#
Bases:
ModelThis model is a performance optimization, updated on course publish.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- course_id#
DO NOT REUSE THIS CLASS. Provided for backwards compatibility only!
A placeholder class that provides a way to set the attribute on the model.
- mapping#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- classmethod update_mapping(course_key, discussions_id_map)#
Update the mapping of discussions IDs to XBlock usage key strings.
- class openedx.core.djangoapps.django_comment_common.models.ForumsConfig(*args, **kwargs)#
Bases:
ConfigurationModelConfig for the connection to the cs_comments_service forums backend.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- property api_key#
The API key used to authenticate to the comments service.
- change_date#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- changed_by#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- changed_by_id#
- connection_timeout#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- enabled#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=True, **kwargs)#
- get_previous_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class openedx.core.djangoapps.django_comment_common.models.Permission(*args, **kwargs)#
Bases:
ModelPermissions for django_comment_client
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- roles#
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- class openedx.core.djangoapps.django_comment_common.models.Role(*args, **kwargs)#
Bases:
ModelMaps users to django_comment_client roles for a given course
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- add_permission(permission)#
- course_id#
DO NOT REUSE THIS CLASS. Provided for backwards compatibility only!
A placeholder class that provides a way to set the attribute on the model.
- has_permission(permission)#
Returns True if this role has the given permission, False otherwise.
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- inherit_permissions(role)#
Make this role inherit permissions from the given role. Permissions are only added, not removed. Does not handle inheritance.
- name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <openedx.core.djangoapps.xmodule_django.models.NoneToEmptyManager object>#
- permissions#
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- static user_has_role_for_course(user, course_id, role_names)#
Returns True if the user has one of the given roles for the given course
- users#
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- openedx.core.djangoapps.django_comment_common.models.all_permissions_for_user_in_course(user, course_id)#
Returns all the permissions the user has in the given course.
- openedx.core.djangoapps.django_comment_common.models.assign_default_role(course_id, user)#
Assign forum default role ‘Student’ to user
- openedx.core.djangoapps.django_comment_common.models.assign_default_role_on_enrollment(sender, instance, **kwargs)#
Assign forum default role ‘Student’
- openedx.core.djangoapps.django_comment_common.models.assign_role(course_id, user, rolename)#
Assign forum role rolename to user
- openedx.core.djangoapps.django_comment_common.models.has_permission(user, permission, course_id=None)#
This function resolves all discussion-related permissions for the given user and course, caches them for the duration of the request, and verifies whether the requested permission is present.
- Parameters:
user (User) – Django user whose permissions are being checked.
permission (str) – Discussion permission identifier (e.g., “create_comment”, “create_thread”).
course_id (CourseKey) – Course context in which to evaluate the permission
- Returns:
True if the user has the specified permission in the given course context; False otherwise.
- Return type:
bool
- openedx.core.djangoapps.django_comment_common.models.permission_blacked_out(course, role_names, permission_name)#
Returns true if a user in course with the given roles would have permission_name blacked out.
This will return true if it is a permission that the user might have normally had for the course, but does not have right this moment because we are in a discussion blackout period (as defined by the settings on the course block). Namely, they can still view, but they can’t edit, update, or create anything. This only applies to students, as moderators of any kind still have posting privileges during discussion blackouts.
openedx.core.djangoapps.django_comment_common.signals module#
Signals related to the comments service.
openedx.core.djangoapps.django_comment_common.utils module#
Common comment client utility functions.
- class openedx.core.djangoapps.django_comment_common.utils.ThreadContext#
Bases:
objectAn enumeration that represents the context of a thread. Used primarily by the comments service.
- COURSE = 'course'#
- STANDALONE = 'standalone'#
- openedx.core.djangoapps.django_comment_common.utils.are_permissions_roles_seeded(course_id)#
Returns whether the forums permissions for a course have been provisioned in the database
- openedx.core.djangoapps.django_comment_common.utils.seed_permissions_roles(course_key)#
Create and assign permissions for forum roles