Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/v3'
Browse files Browse the repository at this point in the history
  • Loading branch information
PanfilovDenis committed Feb 19, 2013
2 parents c385701 + 0c40d99 commit 937595c
Show file tree
Hide file tree
Showing 34 changed files with 252 additions and 54 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ gem 'google-analytics-rails'
gem 'validates'
gem 'virtus'
gem 'js-routes'
gem 'backup'
gem 'whenever'

# Gems used only for assets and not required
# in production environments by default.
Expand Down
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ GEM
ansi (1.4.3)
arel (3.0.2)
backports (2.6.7)
backup (3.0.27)
open4 (~> 1.3.0)
thor (>= 0.15.4, < 2)
bcrypt-ruby (3.0.1)
builder (3.0.4)
capistrano (2.14.1)
Expand All @@ -49,6 +52,7 @@ GEM
carrierwave (0.6.2)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
chronic (0.8.0)
ci_reporter (1.8.3)
builder (>= 2.1.2)
ckeditor (3.7.3)
Expand Down Expand Up @@ -130,6 +134,7 @@ GEM
net-ssh (2.6.3)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
open4 (1.3.0)
orm_adapter (0.4.0)
pg (0.14.1)
polyglot (0.3.3)
Expand Down Expand Up @@ -228,6 +233,9 @@ GEM
virtus (0.5.4)
backports (~> 2.6.1)
descendants_tracker (~> 0.0.1)
whenever (0.8.0)
activesupport (>= 2.3.4)
chronic (>= 0.6.3)
ya_acl (0.0.7)
rake

Expand All @@ -236,6 +244,7 @@ PLATFORMS

DEPENDENCIES
airbrake
backup
bcrypt-ruby (~> 3.0.0)
capistrano
capistrano-ext
Expand Down Expand Up @@ -277,4 +286,5 @@ DEPENDENCIES
usefull_scopes
validates
virtus
whenever
ya_acl
12 changes: 5 additions & 7 deletions app/controllers/web/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
class Web::SessionsController < Web::ApplicationController

def new
@user = UserEditType.new
@type = UserSignInType.new
end

def create
user = UserEditType.find_by_email(params[:user][:email])
@type = UserSignInType.new(params[:user_sign_in_type])

if user.try(:authenticate, params[:user][:password])
if @type.valid?
user = @type.user
flash_success

sign_in(user)
redirect_to root_path
else
flash_error

render action: 'new'
render :new
end
end

Expand Down
25 changes: 19 additions & 6 deletions app/controllers/web/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
class Web::UsersController < Web::ApplicationController

def index
@users = User.shown_as_participants.alphabetically
@users = User.activated.shown_as_participants.alphabetically
end

def new
@user = UserEditType.new
@user = UserRegistrationType.new
end

def activate
token = User::AuthToken.find_by_authentication_token!(params[:auth_token])
user = token.user
if token && user
user.activate!
flash_success
else
flash_error
end
redirect_to root_path
end

def create
@user = UserEditType.new(params[:user])
@user = UserRegistrationType.new(params[:user])

if @user.save
UserMailer.welcome(@user).deliver
sign_in @user
token = @user.create_auth_token
UserMailer.confirm_registration(@user, token).deliver
#sign_in @user
flash_success
redirect_to root_path
redirect_to new_session_path
else
flash_error
render action: "new"
Expand Down
3 changes: 2 additions & 1 deletion app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ class UserMailer < ActionMailer::Base
default_url_options[:host] = configus.mailer.default_host
default from: configus.mailer.default_from

def welcome(user)
def confirm_registration(user, token)
@user = user
@token = token
mail :to => @user.email
end

Expand Down
18 changes: 9 additions & 9 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ class User < ActiveRecord::Base
:show_as_participant, :photo, :state_event, :about

validates :email, presence: true, uniqueness: true, email: true
validates :city, presence: true
validates :first_name, length: {maximum: 20}
validates :last_name, length: {maximum: 20}
validates :city, length: {maximum: 20}
validates :company, length: {maximum: 20}
validates :position, length: {maximum: 20}
validates :first_name, length: { maximum: 255 }
validates :last_name, length: { maximum: 255 }
validates :city, length: { maximum: 255 }
validates :company, length: { maximum: 255 }
validates :position, length: { maximum: 255 }

mount_uploader :photo, UsersPhotoUploader

has_many :auth_tokens

state_machine :state, initial: :active do
state_machine :state, initial: :new do
state :new
state :active
state :inactive

event :activate do
transition any - :active => :active
transition [:inactive, :new] => :active
end

event :deactivate do
transition :active => :inactive
transition [:active, :new] => :inactive
end
end

Expand Down
2 changes: 2 additions & 0 deletions app/repositories/user_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module UserRepository
where show_as_participant: true
}

scope :activated, -> { where state: :active }

scope :alphabetically, -> { order("last_name ASC") }

def self.companies_by_term(company = nil)
Expand Down
1 change: 1 addition & 0 deletions app/types/account_edit_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ class AccountEditType < User

validates :first_name, presence: true
validates :last_name, presence: true
validates :city, presence: true

end
3 changes: 2 additions & 1 deletion app/types/admin/user_edit_type.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
class Admin::UserEditType < User
include BasicType

attr_accessible :password_confirmation, :state_event
attr_accessible :password_confirmation, :state_event, :admin

validates :first_name, presence: true
validates :last_name, presence: true
validates :city, presence: true

end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class UserEditType < User
class UserRegistrationType < User
include BasicType

attr_accessible :password_confirmation, :state_event
Expand All @@ -7,5 +7,7 @@ class UserEditType < User

validates :first_name, presence: true
validates :last_name, presence: true
validates :city, presence: true
validates :password, presence: true, confirmation: true

end
34 changes: 34 additions & 0 deletions app/types/user_sign_in_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class UserSignInType
include ActiveModel::Validations
include ActiveModel::Conversion
include Virtus

attribute :email, String
attribute :password, String

validates :email, presence: true, email: true
validates :password, presence: true

validates_each :email do |record, attr, value|
user = record.user
if user.try :new?
record.errors.add(attr, :user_new)
end

if user.try :inactive?
record.errors.add(attr, :user_inactive)
end

if !user.try(:authenticate, record.password)
record.errors.add(attr, :user_or_password_invalid)
end
end

def persisted?
false
end

def user
@user ||= User.find_by_email(email)
end
end
5 changes: 3 additions & 2 deletions app/views/layouts/web/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
%link{:href => "/favicon.ico", :rel => "icon", :type => "image/x-icon"}/
%link{:href => "/favicon.ico", :rel => "shortcut icon", :type => "image/x-icon"}/
%meta{:content => "http://nastachku.ru/assets/fb_logo.png", :property => "og:image"}
%title= content_for?(:title) ? yield(:title) : "Nastachku"
%meta{:content => "Digital-коммуникации, Программирование, IT-стартапы, Электронная коммерция, Менеджмент в IT, IT на службе общества", :property => "og:description"}
%title= content_for?(:title) ? yield(:title) : "Стачка! Конференция"
= analytics_init if Rails.env.production?
= csrf_meta_tags
= stylesheet_link_tag "application", :media => "all"
Expand All @@ -23,5 +24,5 @@

%br/

= render "layouts/web/shared/reformal"
= render "layouts/web/shared/counters"
= render "layouts/web/shared/footer"
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,36 @@
document.getElementsByTagName('head')[0].appendChild(script);
})();

{}
%noscript
= link_to 'http://reformal.ru' do
= image_tag 'http://media.reformal.ru/reformal.png'
= link_to 'http://nastachku.reformal.ru'


:javascript
(function(w, c) {
   (w[c] = w[c] || []).push(function() {
       try {
           w.yaCounter12986590 = new Ya.Metrika({id:12986590, enableAll: true, webvisor:true});
       }
       catch(e) { }
   });
})(window, "yandex_metrika_callbacks");
(function (d, w, c) {
(w[c] = w[c] || []).push(function() {
try {
w.yaCounter20139103 = new Ya.Metrika({
id:20139103,
webvisor:true,
clickmap:true,
trackLinks:true,
accurateTrackBounce:true
});
} catch(e) { }
});
var n = d.getElementsByTagName("script")[0],
s = d.createElement("script"),
f = function () {
n.parentNode.insertBefore(s, n);
};
s.type = "text/javascript";
s.async = true;
s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js";
if (w.opera == "[object Opera]") {
d.addEventListener("DOMContentLoaded", f, false);
} else {
f();
}
})(document, window, "yandex_metrika_callbacks");

%script(src="//mc.yandex.ru/metrika/watch.js" type="text/javascript" defer="defer")
9 changes: 9 additions & 0 deletions app/views/layouts/web/shared/_liveinternet.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:javascript
document.write("<a href='http://www.liveinternet.ru/click' "+
"target=_blank><img src='//counter.yadro.ru/hit?t42.6;r"+
escape(document.referrer)+((typeof(screen)=="undefined")?"":
";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?
screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+
";"+Math.random()+
"' alt='' title='LiveInternet' "+
"border='0' width='31' height='31'><\/a>")
2 changes: 1 addition & 1 deletion app/views/layouts/web/shared/_navigation.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
%li= link_to t(".i_will_go"), new_user_path
%li= link_to t(".login"), new_session_path
%li= navbar_link t(".participants"), users_path, with: User.shown_as_participants.count
%li= navbar_link t(".participants"), users_path, with: User.activated.count
%li= link_to t(".news"), news_index_path
%li= link_to t(".routes"), page_path(:routes)
%li= link_to t(".contacts"), page_path(:contacts)
Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/web/shared/_social.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
%li
%a{:href => "http://vk.com/nastachku", :target => "_blank"}
%i.ficon-vkontakte-rect
%li=render 'layouts/web/shared/liveinternet'

%nav.social-share-links
%ul
%li.twitter
Expand Down
6 changes: 6 additions & 0 deletions app/views/user_mailer/confirm_registration.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<p>Добрый день, <%= @user.full_name %>.</p>
<p>Ваш почтовый ящик был указан при регистрации на сайте <%= link_to 'nastachku.ru', root_url %>.</p>
<p>Пожалуйста, ПОДТВЕРДИТЕ ВАШУ РЕГИСТРАЦИЮ, пройдя по
<%= link_to 'ссылке', activate_user_url(auth_token: @token.authentication_token) %>
</p>
<p>Не забудьте записать Ваш персональный номер для участия в конференции: <strong><%= @user.id %></strong></p>
1 change: 1 addition & 0 deletions app/views/web/admin/users/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
= f.input :company
= f.input :position
= f.input :show_as_participant
= f.input :admin
= f.input :email
.span4
= f.input :photo, as: :image_preview
Expand Down
4 changes: 2 additions & 2 deletions app/views/web/admin/users/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
%td= link_to user.id, admin_user_path(user)
%td= user.full_name
%td= user.state
%td= user.created_at
%td= l user.created_at
%td
= link_to t('.edit'), edit_admin_user_path(user), :class => 'btn btn-mini'
= link_to t('.destroy'), admin_user_path(user), :method => :delete, :data => { :confirm => t('.confirm') }, :class => 'btn btn-mini btn-danger'
/ = link_to t('.destroy'), admin_user_path(user), :method => :delete, :data => { :confirm => t('.confirm') }, :class => 'btn btn-mini btn-danger'
= link_to t('.new_user'), new_admin_user_path, :class => 'btn btn-primary'
2 changes: 1 addition & 1 deletion app/views/web/admin/users/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
.form-actions
= link_to t('.back'), admin_users_path, :class => 'btn'
= link_to t('.edit'), edit_admin_user_path(@user), :class => 'btn'
= link_to t('.destroy'), admin_user_path(@user), :method => "delete", :data => { :confirm => t('.confirm') }, :class => 'btn btn-danger'
/ = link_to t('.destroy'), admin_user_path(@user), :method => "delete", :data => { :confirm => t('.confirm') }, :class => 'btn btn-danger'
2 changes: 1 addition & 1 deletion app/views/web/sessions/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.formy
%h5= t '.login'
.form
= simple_form_for :user, url: session_path, html: { class: 'form-type-login' } do |f|
= simple_form_for @type, url: session_path, html: { class: 'form-type-login' } do |f|

= f.input :email, :tabindex => 1
= f.input :password, :tabindex => 2
Expand Down

0 comments on commit 937595c

Please sign in to comment.