DEV: changes so plugins can customize invites UI (#9365)
* DEV: changes so plugins can customize invites UI Co-Authored-By: Robin Ward <robin.ward@gmail.com>
This commit is contained in:
parent
4f42bb1fd2
commit
e8fad7a69e
|
@ -0,0 +1,4 @@
|
|||
import Controller from "@ember/controller";
|
||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
|
||||
export default Controller.extend(ModalFunctionality);
|
|
@ -317,8 +317,12 @@ class UsersController < ApplicationController
|
|||
filter_sql = '(LOWER(invites.email) LIKE :filter) or (LOWER(users.username) LIKE :filter)' if show_emails
|
||||
invites = invites.where(filter_sql, filter: "%#{params[:search].downcase}%")
|
||||
end
|
||||
render_json_dump invites: serialize_data(invites.to_a, InviteSerializer, show_emails: show_emails),
|
||||
can_see_invite_details: guardian.can_see_invite_details?(inviter)
|
||||
|
||||
render json: MultiJson.dump(InvitedSerializer.new(
|
||||
OpenStruct.new(invite_list: invites.to_a, show_emails: show_emails, inviter: inviter),
|
||||
scope: guardian,
|
||||
root: false
|
||||
))
|
||||
end
|
||||
|
||||
def invited_count
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class InvitedSerializer < ApplicationSerializer
|
||||
attributes :invites, :can_see_invite_details
|
||||
|
||||
def invites
|
||||
ActiveModel::ArraySerializer.new(
|
||||
object.invite_list,
|
||||
scope: scope,
|
||||
root: false,
|
||||
show_emails: object.show_emails
|
||||
).as_json
|
||||
end
|
||||
|
||||
def can_see_invite_details
|
||||
scope.can_see_invite_details?(object.inviter)
|
||||
end
|
||||
|
||||
def read_attribute_for_serialization(attr)
|
||||
object.respond_to?(attr) ? object.public_send(attr) : public_send(attr)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue