def reorder_realm_custom_profile_fields( request: HttpRequest, user_profile: UserProfile, order: List[int] = REQ(json_validator=check_list(check_int)), ) -> HttpResponse: try_reorder_realm_custom_profile_fields(user_profile.realm, order) return json_success()
def test_list_order(self) -> None: self.login("iago") realm = get_realm("zulip") order = (CustomProfileField.objects.filter( realm=realm).order_by("-order").values_list("order", flat=True)) try_reorder_realm_custom_profile_fields(realm, order) result = self.client_get("/json/realm/profile_fields") content = result.json() self.assertListEqual( content["custom_fields"], sorted(content["custom_fields"], key=lambda x: -x["id"]))
def test_list_order(self) -> None: self.login(self.example_email("iago")) realm = get_realm('zulip') order = ( CustomProfileField.objects.filter(realm=realm) .order_by('-order') .values_list('order', flat=True) ) try_reorder_realm_custom_profile_fields(realm, order) result = self.client_get("/json/realm/profile_fields") content = result.json() self.assertListEqual(content["custom_fields"], sorted(content["custom_fields"], key=lambda x: -x["id"]))
def reorder_realm_custom_profile_fields(request: HttpRequest, user_profile: UserProfile, order: List[int]=REQ(validator=check_list( check_int))) -> HttpResponse: try_reorder_realm_custom_profile_fields(user_profile.realm, order) return json_success()