コード例 #1
0
ファイル: api.py プロジェクト: gopinath81/vmss
def _check_editable_fields(cc_content, data, context):
    """
    Raise ValidationError if the given update data contains a field that is not
    editable by the requesting user
    """
    _check_fields(get_editable_fields(cc_content, context), data,
                  "This field is not editable.")
コード例 #2
0
 def test_thread(self, is_author, is_privileged):
     thread = Thread(user_id="5" if is_author else "6", type="thread")
     context = _get_context(requester_id="5", is_requester_privileged=is_privileged)
     actual = get_editable_fields(thread, context)
     expected = {"following", "voted"}
     if is_author or is_privileged:
         expected |= {"topic_id", "type", "title", "raw_body"}
     self.assertEqual(actual, expected)
コード例 #3
0
 def test_thread(self, is_author, is_privileged):
     thread = Thread(user_id="5" if is_author else "6", type="thread")
     context = _get_context(requester_id="5",
                            is_requester_privileged=is_privileged)
     actual = get_editable_fields(thread, context)
     expected = {"abuse_flagged", "following", "voted"}
     if is_author or is_privileged:
         expected |= {"topic_id", "type", "title", "raw_body"}
     self.assertEqual(actual, expected)
コード例 #4
0
ファイル: api.py プロジェクト: chauhanhardik/populo
def _check_editable_fields(cc_content, data, context):
    """
    Raise ValidationError if the given update data contains a field that is not
    editable by the requesting user
    """
    _check_fields(
        get_editable_fields(cc_content, context),
        data,
        "This field is not editable."
    )
コード例 #5
0
ファイル: api.py プロジェクト: lydia-lee/edx-platform
def _check_editable_fields(cc_content, data, context):
    """
    Raise ValidationError if the given update data contains a field that is not
    in editable_fields.
    """
    editable_fields = get_editable_fields(cc_content, context)
    non_editable_errors = {
        field: ["This field is not editable."]
        for field in data.keys() if field not in editable_fields
    }
    if non_editable_errors:
        raise ValidationError(non_editable_errors)
コード例 #6
0
ファイル: api.py プロジェクト: redukyo/edx-platform
def _check_editable_fields(cc_content, data, context):
    """
    Raise ValidationError if the given update data contains a field that is not
    in editable_fields.
    """
    editable_fields = get_editable_fields(cc_content, context)
    non_editable_errors = {
        field: ["This field is not editable."]
        for field in data.keys()
        if field not in editable_fields
    }
    if non_editable_errors:
        raise ValidationError(non_editable_errors)
コード例 #7
0
 def test_comment(self, is_author, is_thread_author, thread_type, is_privileged):
     comment = Comment(user_id="5" if is_author else "6", type="comment")
     context = _get_context(
         requester_id="5",
         is_requester_privileged=is_privileged,
         thread=Thread(user_id="5" if is_thread_author else "6", thread_type=thread_type)
     )
     actual = get_editable_fields(comment, context)
     expected = {"abuse_flagged", "voted"}
     if is_author or is_privileged:
         expected |= {"raw_body"}
     if (is_thread_author and thread_type == "question") or is_privileged:
         expected |= {"endorsed"}
     self.assertEqual(actual, expected)
コード例 #8
0
 def test_comment(self, is_author, is_thread_author, thread_type, is_privileged):
     comment = Comment(user_id="5" if is_author else "6", type="comment")
     context = _get_context(
         requester_id="5",
         is_requester_privileged=is_privileged,
         thread=Thread(user_id="5" if is_thread_author else "6", thread_type=thread_type)
     )
     actual = get_editable_fields(comment, context)
     expected = {"abuse_flagged", "voted"}
     if is_author or is_privileged:
         expected |= {"raw_body"}
     if (is_thread_author and thread_type == "question") or is_privileged:
         expected |= {"endorsed"}
     self.assertEqual(actual, expected)
コード例 #9
0
ファイル: serializers.py プロジェクト: Qubad786/edx-platform
 def get_editable_fields(self, obj):
     """Return the list of the fields the requester can edit"""
     return sorted(get_editable_fields(obj, self.context))
コード例 #10
0
 def get_editable_fields(self, obj):
     """Return the list of the fields the requester can edit"""
     return sorted(get_editable_fields(obj, self.context))