added authorization and categorizable
This commit is contained in:
parent
f0f98f5c09
commit
0a7cac8ee3
|
@ -1,7 +1,8 @@
|
||||||
class Admin::EmailersController < OrbitAdminController
|
class Admin::EmailersController < OrbitAdminController
|
||||||
|
include Admin::EmailersHelper
|
||||||
|
before_action :load_access_level
|
||||||
def index
|
def index
|
||||||
@table_fields = ["emailer.mail_subject", "emailer.delivery_date", "emailer.created_by", "emailer.status"]
|
@table_fields = [:category, "emailer.mail_subject", "emailer.delivery_date", "emailer.created_by", "emailer.status"]
|
||||||
@emails = EmailEntry.all.order(sort)
|
@emails = EmailEntry.all.order(sort)
|
||||||
@emails = search_data(@emails,[:mail_subject]).page(params[:page]).per(10)
|
@emails = search_data(@emails,[:mail_subject]).page(params[:page]).per(10)
|
||||||
if request.xhr?
|
if request.xhr?
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
module Admin::EmailersHelper
|
||||||
|
|
||||||
|
def load_access_level
|
||||||
|
if (current_user.is_admin? rescue false)
|
||||||
|
@access_level = "admin"
|
||||||
|
elsif (current_user.is_manager?(@module_app) rescue false)
|
||||||
|
@access_level = "manager"
|
||||||
|
else
|
||||||
|
@access_level = "users"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_can_approve?
|
||||||
|
case @access_level
|
||||||
|
when "admin"
|
||||||
|
return true
|
||||||
|
when "manager"
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,4 +0,0 @@
|
||||||
module Emailer
|
|
||||||
module ApplicationHelper
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +1,8 @@
|
||||||
class EmailEntry
|
class EmailEntry
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
|
include OrbitCategory::Categorizable
|
||||||
|
|
||||||
field :mail_subject #not optional
|
field :mail_subject #not optional
|
||||||
field :mail_content #not optional
|
field :mail_content #not optional
|
||||||
field :create_user_id
|
field :create_user_id
|
||||||
|
|
|
@ -24,6 +24,13 @@
|
||||||
|
|
||||||
<!-- Basic Module -->
|
<!-- Basic Module -->
|
||||||
<div class="tab-pane fade in active" id="basic">
|
<div class="tab-pane fade in active" id="basic">
|
||||||
|
<!-- Category -->
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t(:category) %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= select_category(f, @module_app) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted"><%= t("emailer.email_to") %></label>
|
<label class="control-label muted"><%= t("emailer.email_to") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @emails.each do |email| %>
|
<% @emails.each do |email| %>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><%= email.category.title rescue "" %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= email.mail_subject %>
|
<%= email.mail_subject %>
|
||||||
<div class="quick-edit">
|
<div class="quick-edit">
|
||||||
|
@ -21,7 +22,7 @@
|
||||||
<% if can_edit_or_delete?(email) %>
|
<% if can_edit_or_delete?(email) %>
|
||||||
<li><a href="/admin/emailers/<%=email.id.to_s%>/edit"><%= t(:edit) %></a></li>
|
<li><a href="/admin/emailers/<%=email.id.to_s%>/edit"><%= t(:edit) %></a></li>
|
||||||
<li><a data-confirm="Are you sure?" data-method="delete" href="/admin/emailers/<%= email.id.to_s %>" class="delete text-error" ><%= t(:delete_) %></a></li>
|
<li><a data-confirm="Are you sure?" data-method="delete" href="/admin/emailers/<%= email.id.to_s %>" class="delete text-error" ><%= t(:delete_) %></a></li>
|
||||||
<% if !email.approved && current_user.is_admin? %>
|
<% if !email.approved && user_can_approve? %>
|
||||||
<li><a href="/admin/emailers/<%=email.id.to_s%>/approve"><%= t("announcement.approve") %></a>
|
<li><a href="/admin/emailers/<%=email.id.to_s%>/approve"><%= t("announcement.approve") %></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -39,7 +40,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="footable-row-detail">
|
<tr class="footable-row-detail">
|
||||||
<td class="footable-cell-detail" colspan="4">
|
<td class="footable-cell-detail" colspan="5">
|
||||||
<div id="<%= "#{email.id.to_s}-detail" %>" class="footable-row-detail-inner" style="display: none;">
|
<div id="<%= "#{email.id.to_s}-detail" %>" class="footable-row-detail-inner" style="display: none;">
|
||||||
<div>
|
<div>
|
||||||
<strong><%= t("emailer.email_to") %></strong> :
|
<strong><%= t("emailer.email_to") %></strong> :
|
||||||
|
|
|
@ -6,6 +6,7 @@ module Emailer
|
||||||
module_label "emailer.emailer"
|
module_label "emailer.emailer"
|
||||||
base_url File.expand_path File.dirname(__FILE__)
|
base_url File.expand_path File.dirname(__FILE__)
|
||||||
categorizable
|
categorizable
|
||||||
|
authorizable
|
||||||
side_bar do
|
side_bar do
|
||||||
head_label_i18n 'emailer.emailer', icon_class: "icons-mail"
|
head_label_i18n 'emailer.emailer', icon_class: "icons-mail"
|
||||||
available_for "users"
|
available_for "users"
|
||||||
|
@ -21,8 +22,8 @@ module Emailer
|
||||||
context_link 'new_',
|
context_link 'new_',
|
||||||
:link_path=>"new_admin_emailer_path" ,
|
:link_path=>"new_admin_emailer_path" ,
|
||||||
:priority=>2,
|
:priority=>2,
|
||||||
:active_for_action=>{'admin/announcements'=>'new'},
|
:active_for_action=>{'admin/emailers'=>'new'},
|
||||||
:available_for => 'users'
|
:available_for => 'sub_managers'
|
||||||
|
|
||||||
context_link 'categories',
|
context_link 'categories',
|
||||||
:link_path=>"admin_module_app_categories_path" ,
|
:link_path=>"admin_module_app_categories_path" ,
|
||||||
|
|
Loading…
Reference in New Issue