#637: added migration, updated approve_notification
This commit is contained in:
parent
8c06b0c18d
commit
5f941844f2
|
@ -8,6 +8,7 @@ class Users::RegisterRequestsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
params[:register_request][:language] = I18n.locale if params[:register_request]
|
||||||
RegisterRequest.create(params[:register_request])
|
RegisterRequest.create(params[:register_request])
|
||||||
render :thanks
|
render :thanks
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ class UserMailer < ActionMailer::Base
|
||||||
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_user_notification", :project_name => APP_CONFIG['project_name'])) do |format|
|
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_user_notification", :project_name => APP_CONFIG['project_name'])) do |format|
|
||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
end
|
end # new_user_notification
|
||||||
|
|
||||||
def new_comment_notification(comment, user)
|
def new_comment_notification(comment, user)
|
||||||
@user = user
|
@user = user
|
||||||
|
@ -18,7 +18,7 @@ class UserMailer < ActionMailer::Base
|
||||||
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_#{comment.commit_comment? ? 'commit_' : ''}comment_notification")) do |format|
|
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_#{comment.commit_comment? ? 'commit_' : ''}comment_notification")) do |format|
|
||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
end
|
end # new_comment_notification
|
||||||
|
|
||||||
def new_issue_notification(issue, user)
|
def new_issue_notification(issue, user)
|
||||||
@user = user
|
@user = user
|
||||||
|
@ -26,7 +26,7 @@ class UserMailer < ActionMailer::Base
|
||||||
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_issue_notification")) do |format|
|
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_issue_notification")) do |format|
|
||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
end
|
end # new_issue_notification
|
||||||
|
|
||||||
def issue_assign_notification(issue, user)
|
def issue_assign_notification(issue, user)
|
||||||
@user = user
|
@user = user
|
||||||
|
@ -34,10 +34,13 @@ class UserMailer < ActionMailer::Base
|
||||||
mail(:to => user.email, :subject => I18n.t("notifications.subjects.issue_assign_notification")) do |format|
|
mail(:to => user.email, :subject => I18n.t("notifications.subjects.issue_assign_notification")) do |format|
|
||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
end
|
end # issue_assign_notification
|
||||||
|
|
||||||
def invite_approve_notification(register_request)
|
def invite_approve_notification(register_request)
|
||||||
|
I18n.locale = register_request.language if register_request.language
|
||||||
@register_request = register_request
|
@register_request = register_request
|
||||||
mail :to => register_request.email, :subject => I18n.t("notifications.subjects.invite_approve_notification")
|
mail :to => register_request.email, :subject => I18n.t("notifications.subjects.invite_approve_notification") do |format|
|
||||||
end
|
format.html
|
||||||
end
|
end
|
||||||
|
end # invite_approve_notification
|
||||||
|
end # UserMailer
|
||||||
|
|
|
@ -1,34 +1,53 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
class RegisterRequest < ActiveRecord::Base
|
class RegisterRequest < ActiveRecord::Base
|
||||||
|
|
||||||
|
#---------------
|
||||||
|
# *** Scopes ***
|
||||||
|
#+++++++++++++++
|
||||||
|
|
||||||
default_scope order('created_at ASC')
|
default_scope order('created_at ASC')
|
||||||
|
|
||||||
scope :rejected, where(:rejected => true)
|
scope :rejected, where(:rejected => true)
|
||||||
scope :approved, where(:approved => true)
|
scope :approved, where(:approved => true)
|
||||||
scope :unprocessed, where(:approved => false, :rejected => false)
|
scope :unprocessed, where(:approved => false, :rejected => false)
|
||||||
|
|
||||||
# before_create :generate_token
|
#--------------------
|
||||||
before_update :invite_approve_notification
|
# *** Validations ***
|
||||||
|
#++++++++++++++++++++
|
||||||
|
|
||||||
validates :email, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }
|
validates :email, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }
|
||||||
|
|
||||||
|
#------------------
|
||||||
|
# *** Callbacks ***
|
||||||
|
#++++++++++++++++++
|
||||||
|
|
||||||
|
# before_create :generate_token
|
||||||
|
before_update :invite_approve_notification
|
||||||
|
|
||||||
|
#-------------------------
|
||||||
|
# *** Instance Methods ***
|
||||||
|
#+++++++++++++++++++++++++
|
||||||
|
|
||||||
def approve
|
def approve
|
||||||
update_attributes(:approved => true, :rejected => false)
|
update_attributes(:approved => true, :rejected => false)
|
||||||
end
|
end # approve
|
||||||
|
|
||||||
def reject
|
def reject
|
||||||
update_attributes(:approved => false, :rejected => true)
|
update_attributes(:approved => false, :rejected => true)
|
||||||
end
|
end # reject
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def generate_token
|
def generate_token
|
||||||
self.token = Digest::SHA1.hexdigest(name + email + Time.now.to_s + rand.to_s)
|
self.token = Digest::SHA1.hexdigest(name + email + Time.now.to_s + rand.to_s)
|
||||||
end
|
end # generate_token
|
||||||
|
|
||||||
def invite_approve_notification
|
def invite_approve_notification
|
||||||
if approved_changed? and approved == true
|
puts "!!!!!!!!!!========="
|
||||||
|
if approved_changed? && approved?
|
||||||
|
puts "!!!!!!!!!!"
|
||||||
generate_token
|
generate_token
|
||||||
UserMailer.invite_approve_notification(self).deliver
|
UserMailer.invite_approve_notification(self).deliver
|
||||||
end
|
end
|
||||||
end
|
end # invite_approve_notification
|
||||||
end
|
end # RegisterRequest
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
%p== Hello, #{@register_request.name || @register_request.email}.
|
||||||
|
|
||||||
|
%p
|
||||||
|
You have been invited to project «ROSA Build System». Please click on the following link for registration:
|
||||||
|
= link_to 'link', new_user_registration_url(:invitation_token => @register_request.token)
|
||||||
|
|
||||||
|
%p== Support team «ROSA Build System»
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddLanguageToRegisterRequest < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :register_requests, :language, :string
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20120906115648) do
|
ActiveRecord::Schema.define(:version => 20120910094748) do
|
||||||
|
|
||||||
create_table "activity_feeds", :force => true do |t|
|
create_table "activity_feeds", :force => true do |t|
|
||||||
t.integer "user_id", :null => false
|
t.integer "user_id", :null => false
|
||||||
|
@ -351,6 +351,7 @@ ActiveRecord::Schema.define(:version => 20120906115648) do
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "interest"
|
t.string "interest"
|
||||||
t.text "more"
|
t.text "more"
|
||||||
|
t.string "language"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "register_requests", ["email"], :name => "index_register_requests_on_email", :unique => true, :case_sensitive => false
|
add_index "register_requests", ["email"], :name => "index_register_requests_on_email", :unique => true, :case_sensitive => false
|
||||||
|
|
Loading…
Reference in New Issue