diff --git a/app/controllers/register_requests_controller.rb b/app/controllers/register_requests_controller.rb
index 78bd523cc..1c2c9ef35 100644
--- a/app/controllers/register_requests_controller.rb
+++ b/app/controllers/register_requests_controller.rb
@@ -7,26 +7,34 @@ class RegisterRequestsController < ApplicationController
end
def new
- render :layout => 'sessions'
+# render :layout => 'sessions'
+ redirect_to '/invite.html'
end
def show_message
end
def create
- if @register_request = RegisterRequest.create(params[:register_request])
- redirect_to show_message_register_requests_path
- else
- redirect_to :action => :new
+ RegisterRequest.create(params[:register_request])
+ redirect_to '/thanks.html' #show_message_register_requests_path
+ end
+
+ def update
+ case params[:update_type]
+ when 'approve' # see approve method
+ when 'reject' # see reject method
end
+ redirect_to :action => :index
end
def approve
@register_request.update_attributes(:approved => true, :rejected => false)
+ redirect_to :action => :index
end
def reject
@register_request.update_attributes(:approved => false, :rejected => true)
+ redirect_to :action => :index
end
end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 741909db3..113b50dd1 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -27,7 +27,7 @@ class Ability
if user.guest? # Guest rights
can :create, User
- can :create, RegisterRequest
+ can [:create, :show_message], RegisterRequest
else # Registered user rights
can [:show, :autocomplete_user_uname], User
diff --git a/app/models/register_request.rb b/app/models/register_request.rb
index d59416607..ba4fb2295 100644
--- a/app/models/register_request.rb
+++ b/app/models/register_request.rb
@@ -8,7 +8,7 @@ class RegisterRequest < ActiveRecord::Base
before_create :generate_token
validate :name, :presence => true
- validate :email, :presence => true, :uniqueness => {:case_sensitive => false}
+ validate :email, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }
protected
diff --git a/app/views/register_requests/index.html.haml b/app/views/register_requests/index.html.haml
index 88eb17602..a5fcb474d 100644
--- a/app/views/register_requests/index.html.haml
+++ b/app/views/register_requests/index.html.haml
@@ -8,20 +8,40 @@
%h2.title
= t("layout.register_request.list_header")
.inner
- %table.table
- %tr
- %th= t("activerecord.attributes.register_request.name")
- %th= t("activerecord.attributes.register_request.email")
- %th= t("activerecord.attributes.register_request.created_at")
- %th.last
- - @register_requests.each do |request|
- %tr{:class => cycle("odd", "even")}
- %td= request.name
- %td= request.email
- %td
- = link_to t("layout.approve"), register_request_approve_path(request) if can? :approve, request
- |
- = link_to t("layout.reject"), register_request_reject_path(request) if can? :reject, request
+ = form_tag register_requests_path, :method => :put, :class => 'update_form' do
+ = hidden_field_tag 'update_type'
+ %table.table
+ %tr
+ %th
+ %th= t("activerecord.attributes.register_request.name")
+ %th= t("activerecord.attributes.register_request.email")
+ %th= t("activerecord.attributes.register_request.created_at")
+ %th.last
+ - @register_requests.each do |request|
+ %tr{:class => cycle("odd", "even")}
+ %td= check_box_tag 'request_ids[]', request.id
+ %td= request.name
+ %td= request.email
+ %td
+ = link_to t("layout.approve"), register_request_approve_path(request) if can? :approve, request
+ |
+ = link_to t("layout.reject"), register_request_reject_path(request) if can? :reject, request
.actions-bar.wat-cf
.actions
+ = submit_tag t("layout.register_request.approve_selected"), :class => 'approve_registration'
+ = submit_tag t("layout.register_request.reject_selected"), :class => 'reject_registration'
+ .pagination
= will_paginate @register_requests
+:javascript
+ $(function() {
+ var form = $('form.update_form')
+ var change_update_type = function (type) {
+ $('input#update_type').val(type);
+ };
+ $('.approve_registration').live('click', function(e) {
+ //set update_type to 'approve'
+ });
+ $('.approve_registration').live('click', function(e) {
+ //set update_type to 'reject'
+ });
+ });
diff --git a/config/routes.rb b/config/routes.rb
index b4922adc2..0ec6e9dcd 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -12,6 +12,7 @@ Rosa::Application.routes.draw do
collection do
resources :register_requests, :only => [:index, :new, :create, :show_message, :approve, :reject] do
get :show_message, :on => :collection
+ put :update, :on => :collection
get :approve
get :reject
end
diff --git a/public/invite.html b/public/invite.html
new file mode 100644
index 000000000..32ac74325
--- /dev/null
+++ b/public/invite.html
@@ -0,0 +1,94 @@
+
+
+
+
+ Сборочная среда
+
+
+
+
+
+
+
+
+
+
+
+ Платформа разработки и управления жизненным циклом дистрибутивов: от исходного кода до ISO-образов
+
+
+
+
+
+
+
+
+
+
Здравствуйте, вы попали на страницу нашего нового сервиса ABF, который сейчас проходит тестирование.
+ Это проект универсального build-сервера ABF, цель которого — автоматизировать согласование зависимостей при пересборке пакетов, облегчить работу билд-менеджеров, гарантировать, что все пакеты в образе собраны без конфликтов друг с другом.