diff --git a/app/assets/javascripts/admins/system_notifications/index.js b/app/assets/javascripts/admins/system_notifications/index.js new file mode 100644 index 000000000..90809b344 --- /dev/null +++ b/app/assets/javascripts/admins/system_notifications/index.js @@ -0,0 +1,76 @@ +/* + * @Description: Do not edit + * @Date: 2021-08-31 11:16:45 + * @LastEditors: viletyy + * @Author: viletyy + * @LastEditTime: 2021-08-31 14:19:46 + * @FilePath: /forgeplus/app/assets/javascripts/admins/system_notifications/index.js + */ +$(document).on('turbolinks:load', function(){ + + var showSuccessNotify = function() { + $.notify({ + message: '操作成功' + },{ + type: 'success' + }); + } + + // close user + $('.system-notification-list-container').on('click', '.close-action', function(){ + var $closeAction = $(this); + var $uncloseAction = $closeAction.siblings('.unclose-action'); + + var keywordID = $closeAction.data('id'); + customConfirm({ + content: '确认取消置顶吗?', + ok: function(){ + $.ajax({ + url: '/admins/system_notifications/' + keywordID, + method: 'PUT', + dataType: 'json', + data: { + system_notification: { + is_top: false + } + }, + success: function() { + showSuccessNotify(); + $closeAction.hide(); + $uncloseAction.show(); + $(".system-notification-item-"+keywordID).children('td').eq(3).text("") + } + }); + } + }); + }); + + // unclose user + $('.system-notification-list-container').on('click', '.unclose-action', function(){ + var $uncloseAction = $(this); + var $closeAction = $uncloseAction.siblings('.close-action'); + + var keywordID = $uncloseAction.data('id'); + customConfirm({ + content: '确认置顶吗?', + ok: function () { + $.ajax({ + url: '/admins/system_notifications/' + keywordID, + method: 'PUT', + dataType: 'json', + data: { + system_notification: { + is_top: true + } + }, + success: function() { + showSuccessNotify(); + $closeAction.show(); + $uncloseAction.hide(); + $(".system-notification-item-"+keywordID).children('td').eq(3).text("√") + } + }); + } + }) + }); +}) \ No newline at end of file diff --git a/app/controllers/admins/system_notifications_controller.rb b/app/controllers/admins/system_notifications_controller.rb new file mode 100644 index 000000000..0dc7dd2a2 --- /dev/null +++ b/app/controllers/admins/system_notifications_controller.rb @@ -0,0 +1,71 @@ +class Admins::SystemNotificationsController < Admins::BaseController + before_action :get_notification, only: [:history, :edit,:update, :destroy] + # before_action :validate_identifer, only: [:create, :update] + + def index + sort_by = SystemNotification.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_at' + sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc' + q = SystemNotification.ransack(subject_cont: params[:search]) + notifications = q.result(distinct: true).reorder("#{sort_by} #{sort_direction},created_at desc") + @notifications = paginate(notifications) + end + + def new + @notification = SystemNotification.new + end + + def edit + end + + def create + @notification = SystemNotification.new(notification_params) + if @notification.save + redirect_to admins_system_notifications_path + flash[:success] = '系统消息创建成功' + else + redirect_to admins_system_notifications_path + flash[:danger] = @notification.errors.full_messages.join(",") + end + end + + def update + respond_to do |format| + if @notification.update_attributes(notification_params) + format.html do + redirect_to admins_system_notifications_path + flash[:success] = '系统消息更新成功' + end + format.js {render_ok} + else + format.html do + redirect_to admins_system_notifications_path + flash[:danger] = @notification.errors.full_messages.join(",") + end + format.js {render_js_error} + end + end + end + + def destroy + if @notification.destroy + redirect_to admins_system_notifications_path + flash[:success] = "系统消息删除成功" + else + redirect_to admins_system_notifications_path + flash[:danger] = "系统消息删除失败" + end + end + + private + def notification_params + params.require(:system_notification).permit! + end + + def get_notification + @notification = SystemNotification.find_by(id: params[:id]) + unless @notification.present? + redirect_to admins_system_notifications_path + flash[:danger] = "系统消息不存在" + end + end +end \ No newline at end of file diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index f16edbb38..446c699e2 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -111,8 +111,8 @@ class IssuesController < ApplicationController Issues::CreateForm.new({subject:issue_params[:subject]}).validate! @issue = Issue.new(issue_params) if @issue.save! - SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @issue&.id) - SendTemplateMessageJob.perform_later('ProjectIssue', current_user.id, @issue&.id) + SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @issue&.id) if Site.has_notice_menu? + SendTemplateMessageJob.perform_later('ProjectIssue', current_user.id, @issue&.id) if Site.has_notice_menu? if params[:attachment_ids].present? params[:attachment_ids].each do |id| attachment = Attachment.select(:id, :container_id, :container_type)&.find_by_id(id) @@ -206,8 +206,8 @@ class IssuesController < ApplicationController Issues::UpdateForm.new({subject:issue_params[:subject]}).validate! if @issue.update_attributes(issue_params) if @issue&.pull_request.present? - SendTemplateMessageJob.perform_later('PullRequestChanged', current_user.id, @issue&.pull_request&.id, @issue.previous_changes.slice(:assigned_to_id, :priority_id, :fixed_version_id, :issue_tags_value)) - SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @issue&.pull_request&.id ) if @issue.previous_changes[:assigned_to_id].present? + SendTemplateMessageJob.perform_later('PullRequestChanged', current_user.id, @issue&.pull_request&.id, @issue.previous_changes.slice(:assigned_to_id, :priority_id, :fixed_version_id, :issue_tags_value)) if Site.has_notice_menu? + SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @issue&.pull_request&.id ) if @issue.previous_changes[:assigned_to_id].present? && Site.has_notice_menu? else previous_changes = @issue.previous_changes.slice(:status_id, :assigned_to_id, :tracker_id, :priority_id, :fixed_version_id, :done_ratio, :issue_tags_value, :branch_name) if @issue.previous_changes[:start_date].present? @@ -222,8 +222,8 @@ class IssuesController < ApplicationController if @issue.previous_changes[:status_id].present? && @issue.previous_changes[:status_id][0] == 5 @issue.project_trends.where(action_type: ProjectTrend::CLOSE).destroy_all end - SendTemplateMessageJob.perform_later('IssueChanged', current_user.id, @issue&.id, previous_changes) - SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @issue&.id) if @issue.previous_changes[:assigned_to_id].present? + SendTemplateMessageJob.perform_later('IssueChanged', current_user.id, @issue&.id, previous_changes) if Site.has_notice_menu? + SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @issue&.id) if @issue.previous_changes[:assigned_to_id].present? && Site.has_notice_menu? end if params[:status_id].to_i == 5 #任务由非关闭状态到关闭状态时 @issue.issue_times.update_all(end_time: Time.now) @@ -276,7 +276,7 @@ class IssuesController < ApplicationController status_id = @issue.status_id token = @issue.token login = @issue.user.try(:login) - SendTemplateMessageJob.perform_later('IssueDeleted', current_user.id, @issue&.subject, @issue.assigned_to_id, @issue.author_id) + SendTemplateMessageJob.perform_later('IssueDeleted', current_user.id, @issue&.subject, @issue.assigned_to_id, @issue.author_id) if Site.has_notice_menu? if @issue.destroy if issue_type == "2" && status_id != 5 post_to_chain("add", token, login) @@ -299,7 +299,7 @@ class IssuesController < ApplicationController issues = Issue.where(id: issue_ids, issue_type: "1") if issues.present? issues.find_each do |i| - SendTemplateMessageJob.perform_later('IssueDeleted', current_user.id, i&.subject, i.assigned_to_id, i.author_id) + SendTemplateMessageJob.perform_later('IssueDeleted', current_user.id, i&.subject, i.assigned_to_id, i.author_id) if Site.has_notice_menu? end if issues.destroy_all normal_status(0, "删除成功") @@ -350,8 +350,8 @@ class IssuesController < ApplicationController if i.previous_changes[:status_id].present? && i.previous_changes[:status_id][0] == 5 i.project_trends.where(action_type: ProjectTrend::CLOSE).destroy_all end - SendTemplateMessageJob.perform_later('IssueChanged', current_user.id, i&.id, previous_changes) - SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, i&.id) if i.previous_changes[:assigned_to_id].present? + SendTemplateMessageJob.perform_later('IssueChanged', current_user.id, i&.id, previous_changes) if Site.has_notice_menu? + SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, i&.id) if i.previous_changes[:assigned_to_id].present? && Site.has_notice_menu? end normal_status(0, "批量更新成功") else @@ -366,8 +366,8 @@ class IssuesController < ApplicationController @new_issue = @issue.dup @new_issue.author_id = current_user.id if @new_issue.save - SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @new_issue&.id) - SendTemplateMessageJob.perform_later('ProjectIssue', current_user.id, @new_issue&.id) + SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @new_issue&.id) if Site.has_notice_menu? + SendTemplateMessageJob.perform_later('ProjectIssue', current_user.id, @new_issue&.id) if Site.has_notice_menu? issue_tags = @issue.issue_tags.pluck(:id) if issue_tags.present? issue_tags.each do |tag| diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 0af4898fc..77087770a 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -9,8 +9,8 @@ class MembersController < ApplicationController def create interactor = Projects::AddMemberInteractor.call(@project.owner, @project, @user) - SendTemplateMessageJob.perform_later('ProjectJoined', current_user.id, @user.id, @project.id) - SendTemplateMessageJob.perform_later('ProjectMemberJoined', current_user.id, @user.id, @project.id) + SendTemplateMessageJob.perform_later('ProjectJoined', current_user.id, @user.id, @project.id) if Site.has_notice_menu? + SendTemplateMessageJob.perform_later('ProjectMemberJoined', current_user.id, @user.id, @project.id) if Site.has_notice_menu? render_response(interactor) rescue Exception => e uid_logger_error(e.message) @@ -30,8 +30,8 @@ class MembersController < ApplicationController def remove interactor = Projects::DeleteMemberInteractor.call(@project.owner, @project, @user) - SendTemplateMessageJob.perform_later('ProjectLeft', current_user.id, @user.id, @project.id) - SendTemplateMessageJob.perform_later('ProjectMemberLeft', current_user.id, @user.id, @project.id) + SendTemplateMessageJob.perform_later('ProjectLeft', current_user.id, @user.id, @project.id) if Site.has_notice_menu? + SendTemplateMessageJob.perform_later('ProjectMemberLeft', current_user.id, @user.id, @project.id) if Site.has_notice_menu? render_response(interactor) rescue Exception => e uid_logger_error(e.message) @@ -40,7 +40,7 @@ class MembersController < ApplicationController def change_role interactor = Projects::ChangeMemberRoleInteractor.call(@project.owner, @project, @user, params[:role]) - SendTemplateMessageJob.perform_later('ProjectRole', current_user.id, @user.id, @project.id, message_role_name) + SendTemplateMessageJob.perform_later('ProjectRole', current_user.id, @user.id, @project.id, message_role_name) if Site.has_notice_menu? render_response(interactor) rescue Exception => e uid_logger_error(e.message) diff --git a/app/controllers/organizations/team_users_controller.rb b/app/controllers/organizations/team_users_controller.rb index c63005260..0a5ff28a1 100644 --- a/app/controllers/organizations/team_users_controller.rb +++ b/app/controllers/organizations/team_users_controller.rb @@ -18,7 +18,7 @@ class Organizations::TeamUsersController < Organizations::BaseController ActiveRecord::Base.transaction do @team_user = TeamUser.build(@organization.id, @operate_user.id, @team.id) @organization_user = OrganizationUser.build(@organization.id, @operate_user.id) - SendTemplateMessageJob.perform_later('OrganizationRole', @operate_user.id, @organization.id, @team.authorize_name) + SendTemplateMessageJob.perform_later('OrganizationRole', @operate_user.id, @organization.id, @team.authorize_name) if Site.has_notice_menu? Gitea::Organization::TeamUser::CreateService.call(@organization.gitea_token, @team.gtid, @operate_user.login) end rescue Exception => e diff --git a/app/controllers/projects/project_units_controller.rb b/app/controllers/projects/project_units_controller.rb index e8b8f67a1..52cd857d1 100644 --- a/app/controllers/projects/project_units_controller.rb +++ b/app/controllers/projects/project_units_controller.rb @@ -7,7 +7,7 @@ class Projects::ProjectUnitsController < Projects::BaseController if current_user.admin? || @project.manager?(current_user) ActiveRecord::Base.transaction do before_units, after_units = ProjectUnit.update_by_unit_types!(@project, unit_types) - SendTemplateMessageJob.perform_later('ProjectSettingChanged', current_user.id, @project&.id, {navbar: true}) unless before_units.eql?(after_units) + SendTemplateMessageJob.perform_later('ProjectSettingChanged', current_user.id, @project&.id, {navbar: true}) unless before_units.eql?(after_units) if Site.has_notice_menu? render_ok end else diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 0dbb666bf..3c5cb1f32 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -145,7 +145,7 @@ class ProjectsController < ApplicationController gitea_repo = Gitea::Repository::UpdateService.call(@owner, @project&.repository&.identifier, gitea_params) @project.repository.update_attributes({hidden: gitea_repo["private"], identifier: gitea_repo["name"]}) end - SendTemplateMessageJob.perform_later('ProjectSettingChanged', current_user.id, @project&.id, @project.previous_changes.slice(:name, :description, :project_category_id, :project_language_id, :is_public)) + SendTemplateMessageJob.perform_later('ProjectSettingChanged', current_user.id, @project&.id, @project.previous_changes.slice(:name, :description, :project_category_id, :project_language_id, :is_public)) if Site.has_notice_menu? end rescue Exception => e uid_logger_error(e.message) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index ac3968aad..342f063d2 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -59,8 +59,8 @@ class PullRequestsController < ApplicationController @pull_request, @gitea_pull_request = PullRequests::CreateService.call(current_user, @owner, @project, params) if @gitea_pull_request[:status] == :success @pull_request.bind_gitea_pull_request!(@gitea_pull_request[:body]["number"], @gitea_pull_request[:body]["id"]) - SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @pull_request&.id) - SendTemplateMessageJob.perform_later('ProjectPullRequest', current_user.id, @pull_request&.id) + SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @pull_request&.id) if Site.has_notice_menu? + SendTemplateMessageJob.perform_later('ProjectPullRequest', current_user.id, @pull_request&.id) if Site.has_notice_menu? else render_error("create pull request error: #{@gitea_pull_request[:status]}") raise ActiveRecord::Rollback @@ -118,8 +118,8 @@ class PullRequestsController < ApplicationController normal_status(-1, e.message) raise ActiveRecord::Rollback end - SendTemplateMessageJob.perform_later('PullRequestChanged', current_user.id, @pull_request&.id, @issue.previous_changes.slice(:assigned_to_id, :priority_id, :fixed_version_id, :issue_tags_value)) - SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @pull_request&.id ) if @issue.previous_changes[:assigned_to_id].present? + SendTemplateMessageJob.perform_later('PullRequestChanged', current_user.id, @pull_request&.id, @issue.previous_changes.slice(:assigned_to_id, :priority_id, :fixed_version_id, :issue_tags_value)) if Site.has_notice_menu? + SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @pull_request&.id ) if @issue.previous_changes[:assigned_to_id].present? && Site.has_notice_menu? end end @@ -131,7 +131,7 @@ class PullRequestsController < ApplicationController colsed = PullRequests::CloseService.call(@owner, @repository, @pull_request, current_user) if colsed === true @pull_request.project_trends.create!(user: current_user, project: @project,action_type: ProjectTrend::CLOSE) - SendTemplateMessageJob.perform_later('PullRequestClosed', current_user.id, @pull_request.id) + SendTemplateMessageJob.perform_later('PullRequestClosed', current_user.id, @pull_request.id) if Site.has_notice_menu? normal_status(1, "已拒绝") else normal_status(-1, '合并失败') @@ -175,7 +175,7 @@ class PullRequestsController < ApplicationController # @pull_request.project_trend_status! @pull_request.project_trends.create!(user: current_user, project: @project,action_type: ProjectTrend::MERGE) @issue&.custom_journal_detail("merge", "", "该合并请求已被合并", current_user&.id) - SendTemplateMessageJob.perform_later('PullRequestMerged', current_user.id, @pull_request.id) + SendTemplateMessageJob.perform_later('PullRequestMerged', current_user.id, @pull_request.id) if Site.has_notice_menu? normal_status(1, "合并成功") else normal_status(-1, result.message) diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index b6662f661..b2dc2e900 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -4,7 +4,7 @@ class SettingsController < ApplicationController get_add_menu get_common_menu get_personal_menu - + get_top_system_notification end private @@ -40,6 +40,10 @@ class SettingsController < ApplicationController end end + def get_top_system_notification + @top_system_notification = SystemNotification.is_top.first + end + def get_site_url(key, value) key.to_s === "url" ? append_http(reset_site_url(value)) : reset_site_url(value) end diff --git a/app/controllers/users/messages_controller.rb b/app/controllers/users/messages_controller.rb index 035441ccb..5116f580f 100644 --- a/app/controllers/users/messages_controller.rb +++ b/app/controllers/users/messages_controller.rb @@ -18,16 +18,16 @@ class Users::MessagesController < Users::BaseController Notice::Write::CreateAtmeForm.new(atme_params).validate! case atme_params[:atmeable_type] when 'Issue' - SendTemplateMessageJob.perform_now('IssueAtme', @receivers, current_user.id, atme_params[:atmeable_id]) + SendTemplateMessageJob.perform_now('IssueAtme', @receivers, current_user.id, atme_params[:atmeable_id]) if Site.has_notice_menu? when 'PullRequest' - SendTemplateMessageJob.perform_now('PullRequestAtme', @receivers, current_user.id, atme_params[:atmeable_id]) + SendTemplateMessageJob.perform_now('PullRequestAtme', @receivers, current_user.id, atme_params[:atmeable_id]) if Site.has_notice_menu? when 'Journal' journal = Journal.find_by_id(atme_params[:atmeable_id]) if journal.present? if journal&.issue&.pull_request.present? - SendTemplateMessageJob.perform_now('PullRequestAtme', @receivers, current_user.id, atme_params[:atmeable_id]) + SendTemplateMessageJob.perform_now('PullRequestAtme', @receivers, current_user.id, atme_params[:atmeable_id]) if Site.has_notice_menu? else - SendTemplateMessageJob.perform_now('IssueAtme', @receivers, current_user.id, atme_params[:atmeable_id]) + SendTemplateMessageJob.perform_now('IssueAtme', @receivers, current_user.id, atme_params[:atmeable_id]) if Site.has_notice_menu? end end end diff --git a/app/jobs/delay_expired_issue_job.rb b/app/jobs/delay_expired_issue_job.rb index 4633a953d..bf0e1d2e4 100644 --- a/app/jobs/delay_expired_issue_job.rb +++ b/app/jobs/delay_expired_issue_job.rb @@ -3,8 +3,8 @@ class DelayExpiredIssueJob < ApplicationJob def perform Issue.where(due_date: Date.today + 1.days).find_each do |issue| - SendTemplateMessageJob.perform_later('IssueAssignerExpire', issue.id) - SendTemplateMessageJob.perform_later('IssueCreatorExpire', issue.id) + SendTemplateMessageJob.perform_later('IssueAssignerExpire', issue.id) if Site.has_notice_menu? + SendTemplateMessageJob.perform_later('IssueCreatorExpire', issue.id) if Site.has_notice_menu? end end diff --git a/app/models/organization_user.rb b/app/models/organization_user.rb index 1ad2abd9a..4ff6946b7 100644 --- a/app/models/organization_user.rb +++ b/app/models/organization_user.rb @@ -36,10 +36,10 @@ class OrganizationUser < ApplicationRecord end def send_create_message_to_notice_system - SendTemplateMessageJob.perform_later('OrganizationJoined', self.user_id, self.organization_id) + SendTemplateMessageJob.perform_later('OrganizationJoined', self.user_id, self.organization_id) if Site.has_notice_menu? end def send_destroy_message_to_notice_system - SendTemplateMessageJob.perform_later('OrganizationLeft', self.user_id, self.organization_id) + SendTemplateMessageJob.perform_later('OrganizationLeft', self.user_id, self.organization_id) if Site.has_notice_menu? end end diff --git a/app/models/site.rb b/app/models/site.rb index de352dcc5..af5e78169 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -26,6 +26,10 @@ class Site < ApplicationRecord set_common_menu! end + def self.has_notice_menu? + self.common.where(key: 'notice').present? + end + private def self.set_add_menu! adds= [ diff --git a/app/models/system_notification.rb b/app/models/system_notification.rb new file mode 100644 index 000000000..6f901b3fd --- /dev/null +++ b/app/models/system_notification.rb @@ -0,0 +1,20 @@ +# == Schema Information +# +# Table name: system_notifications +# +# id :integer not null, primary key +# subject :string(255) +# sub_subject :string(255) +# content :text(65535) +# is_top :boolean +# created_at :datetime not null +# updated_at :datetime not null +# + +class SystemNotification < ApplicationRecord + + default_scope { order(created_at: :desc)} + + scope :is_top, lambda { where(is_top: true) } + +end diff --git a/app/models/user.rb b/app/models/user.rb index 3c4a900a0..623694b33 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -170,7 +170,7 @@ class User < Owner has_many :issues, dependent: :destroy, foreign_key: :author_id has_many :pull_requests, dependent: :destroy has_many :public_keys, class_name: "Gitea::PublicKey",primary_key: :gitea_uid, foreign_key: :owner_id, dependent: :destroy - + # Groups and active users scope :active, lambda { where(status: STATUS_ACTIVE) } scope :like, lambda { |keywords| diff --git a/app/models/watcher.rb b/app/models/watcher.rb index 7ff20943e..6a8c94fcc 100644 --- a/app/models/watcher.rb +++ b/app/models/watcher.rb @@ -37,7 +37,7 @@ class Watcher < ApplicationRecord end def send_create_message_to_notice_system - SendTemplateMessageJob.perform_later('FollowTip', self.id) if self.watchable.is_a?(User) + SendTemplateMessageJob.perform_later('FollowTip', self.id) if self.watchable.is_a?(User) if Site.has_notice_menu? end end diff --git a/app/services/projects/accept_join_service.rb b/app/services/projects/accept_join_service.rb index b1a996fd8..2bbacad69 100644 --- a/app/services/projects/accept_join_service.rb +++ b/app/services/projects/accept_join_service.rb @@ -53,8 +53,8 @@ class Projects::AcceptJoinService < ApplicationService def operate_project_member Projects::AddMemberInteractor.call(@project.owner, @project, @applied_project.user, permission) - SendTemplateMessageJob.perform_later('ProjectJoined', @user.id, @applied_project.user_id, @project.id) - SendTemplateMessageJob.perform_later('ProjectMemberJoined', @user.id, @applied_project.user_id, @project.id) + SendTemplateMessageJob.perform_later('ProjectJoined', @user.id, @applied_project.user_id, @project.id) if Site.has_notice_menu? + SendTemplateMessageJob.perform_later('ProjectMemberJoined', @user.id, @applied_project.user_id, @project.id) if Site.has_notice_menu? end def send_apply_message diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index 402449b3b..75abbc124 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -30,8 +30,6 @@
序号 | +标题 | +副标题 | +<%= sort_tag('是否置顶', name: 'is_top', path: admins_system_notifications_path) %> | +<%= sort_tag('创建时间', name: 'created_at', path: admins_system_notifications_path) %> | +操作 | +
---|---|---|---|---|---|
<%= list_index_no((params[:page] || 1).to_i, index) %> | +<%= notification.subject %> | +<%= notification.sub_subject %> | +<%= notification.is_top ? '√' : '' %> | +<%= notification.created_at&.strftime('%Y-%m-%d %H:%M') %> | ++ <%= javascript_void_link '置顶', class: 'action unclose-action', data: { id: notification.id }, style: notification.is_top ? 'display: none;' : '' %> + <%= javascript_void_link '取消置顶', class: 'action close-action', data: { id: notification.id }, style: notification.is_top ? '' : 'display: none;' %> + <%= link_to "编辑", edit_admins_system_notification_path(notification), remote: true, class: "action" %> + <%= link_to "删除", admins_system_notification_path(notification), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %> + | +