class ResourcesController < ApplicationController def show if list_of_canonical_resources.include? params[:kind] @resource_name = params[:kind] end begin res = api.my_resources['data'] if @resource_name res = res.select{|uid| uid =~ /^#{@resource_name}:/} || [] end @resources = res rescue ApiBackend::ApiError flash[:danger] = :failed redirect_to root_path end end def create flash[:warning] = nil @resource_names = list_of_canonical_resources @resource_quota = api.resource_quota @resource_name = params[:resource_name] @resource_name = nil unless @resource_names.include?(@resource_name) if @resource_name @resource_schema = api.resource_user_schema(@resource_name)['schema'] end if @resource_name == 'schleuder' begin WkdSrvClient.get(current_user) rescue @disabled = true flash[:warning] = 'missing_gpg_key' end end end def do_create @resource_name = params[:resource_name] if list_of_canonical_resources.include? @resource_name data = {} data['name'] = params[:localpart] data['domain'] = params[:domain] @res = api.resource_self_create(@resource_name, data) update_account_properties if @resource_name == 'mailman' || @resource_name == 'schleuder' flash[:success] = :resource_created else flash[:success] = :resource_created_now end end redirect_to action: :show, kind: @resource_name rescue ApiError => e flash[:danger] = e.api_msg redirect_to new_resource_path end def update uid = params[:uid] pw = params[:password] if params[:delete].present? @res = api.resource_delete(uid, pw) flash[:success] = :success end redirect_to action: :show, kind: params[:kind] rescue ApiError => e flash[:danger] = e.api_msg redirect_to action: :show, kind: params[:kind] end end