mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-28 01:56:01 -05:00
37cea49459
- allow the configuration of an inbox-email-address per category - post emails to that email into that category instead of global - Adds UI for configuration - Adds Documentation for configuration - Adds Tests for new feature
43 lines
1,001 B
Ruby
43 lines
1,001 B
Ruby
class CategorySerializer < BasicCategorySerializer
|
|
|
|
attributes :read_restricted,
|
|
:available_groups,
|
|
:auto_close_hours,
|
|
:group_permissions,
|
|
:position,
|
|
:email_in,
|
|
:can_delete
|
|
|
|
def group_permissions
|
|
@group_permissions ||= begin
|
|
perms = object.category_groups.joins(:group).includes(:group).order("groups.name").map do |cg|
|
|
{
|
|
permission_type: cg.permission_type,
|
|
group_name: cg.group.name
|
|
}
|
|
end
|
|
if perms.length == 0 && !object.read_restricted
|
|
perms << {permission_type: CategoryGroup.permission_types[:full], group_name: :everyone}
|
|
end
|
|
perms
|
|
end
|
|
end
|
|
|
|
def available_groups
|
|
Group.order(:name).pluck(:name) - group_permissions.map{|g| g[:group_name]}
|
|
end
|
|
|
|
|
|
def can_delete
|
|
true
|
|
end
|
|
|
|
def include_can_delete?
|
|
scope && scope.can_delete?(object)
|
|
end
|
|
|
|
def include_email_in?
|
|
scope && scope.can_edit?(object)
|
|
end
|
|
|
|
end
|