Skip to content
Browse files

Profile show

  • Loading branch information...
1 parent b802e3d commit 8bdffba25d5b59273352e31a2ba948f46a630127 @ck3g committed Mar 23, 2013
View
BIN app/assets/images/flags/europeanunion.png
Deleted file not rendered
View
2 app/assets/stylesheets/profiles.css.scss
@@ -1,3 +1,5 @@
// Place all the styles related to the profiles controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
+
+.achievements { background: url("bnet/achievements.png") no-repeat scroll 0 -41px transparent; padding-left: 15px; }
View
1 app/controllers/profiles_controller.rb
@@ -6,6 +6,7 @@ class ProfilesController < ApplicationController
before_filter :find_profile
def show
+ respond_with @profile
end
def edit
View
13 app/helpers/profiles_helper.rb
@@ -1,2 +1,15 @@
module ProfilesHelper
+ def profile_attribute_block(title, value)
+ content_tag :p do
+ "<strong>#{title}:</strong>".html_safe + " #{(value if value.present?)}"
+ end
+ end
+
+ def avatar_html(profile)
+ if profile.avatar_style?
+ content_tag :div, "", style: profile.avatar_style
+ else
+ image_tag "bnet/avatar.gif", alt: "Avatar", size: "90x90"
+ end
+ end
end
View
20 app/models/profile.rb
@@ -6,5 +6,23 @@ class Profile < ActiveRecord::Base
:last_name, :details, :avatar_style, :achievements, :rank, :points, :wins, :loses, :win_rate,
:profile_url, :synchronized_at
- delegate :email, to: :user, prefix: true
+ delegate :email, :current_sign_in_at, to: :user, prefix: true
+ delegate :username, to: :user, prefix: false
+ delegate :name, to: :country, prefix: true, allow_nil: true
+
+ def fullname
+ "#{first_name} #{last_name}"
+ end
+
+ def has_played_games?
+ wins > 0
+ end
+
+ def has_league?
+ league.present? && league != "_"
+ end
+
+ def league_parts
+ league.split "_"
+ end
end
View
59 app/views/profiles/show.html.haml
@@ -6,4 +6,61 @@
.row-fluid
.pull-left
- %h3= t(:user_profile, user: @profile.user_email)
+ %h3= t(:user_profile, user: @profile.username)
+ .row-fluid
+ .span12
+ %fieldset
+ %legend= t(:common_info)
+ = profile_attribute_block Profile.human_attribute_name(:username), @profile.username
+ = profile_attribute_block Profile.human_attribute_name(:fullname), @profile.fullname
+ = profile_attribute_block Profile.human_attribute_name(:country), @profile.country_name
+ = profile_attribute_block Profile.human_attribute_name(:created_at), l(@profile.created_at, format: :long)
+ = profile_attribute_block Profile.human_attribute_name(:user_current_sign_in_at), l(@profile.user_current_sign_in_at, format: :long)
+
+ - if @profile.profile_url?
+ .row-fluid
+ .span12
+ .span8
+ %fieldset
+ %legend= t(:battlenet_info)
+ .span12
+ .span2
+ = avatar_html @profile
+ - if can? :manage, @profile
+ = link_to t(:reload), "#", class: "btn"
+ .span10
+ %p
+ %strong= "#{Profile.human_attribute_name(:bnet_name)}:"
+ = link_to @profile.bnet_name, @profile.profile_url, rel: "nofollow"
+ %p
+ %strong= "#{Profile.human_attribute_name(:server)}:"
+ = image_tag "flags/#{@profile.bnet_server}.png", alt: t("bnet_servers.#{@profile.bnet_server}")
+ = t("bnet_servers.#{@profile.bnet_server}")
+
+ %p
+ %strong= "#{Profile.human_attribute_name(:achievements)}:"
+ %span.achievements= @profile.achievements
+ =# TODO: race
+ = profile_attribute_block Profile.human_attribute_name(:synchronized_at), l(@profile.synchronized_at, format: :long)
+
+ .span4
+ %fieldset
+ %legend= t(:game_stats)
+ - if @profile.has_played_games?
+ - badge, badge_medium = @profile.league_parts
+ - if badge && badge_medium
+ %span.badge{class: "badge-#{badge} badge-medium-#{badge_medium}"}
+ = profile_attribute_block Profile.human_attribute_name(:game_type), "1x1"
+ = profile_attribute_block Profile.human_attribute_name(:rank), @profile.rank
+ = profile_attribute_block Profile.human_attribute_name(:points), @profile.points
+ = profile_attribute_block Profile.human_attribute_name(:wins), @profile.wins
+ - else
+ = t(:no_played_games_yet)
+
+ - if @profile.details?
+ .row-fluid
+ .span12
+ %fieldset
+ %legend= Profile.human_attribute_name(:details)
+ = simple_format @profile.details
+
View
12 config/locales/models/profile.ru.yml
@@ -9,3 +9,15 @@ ru:
country_id: Страна проживания
profile_url: Сслыка на Battle.Net провайл
details: Дополнительная информация
+ username: Никнейм на сайте
+ fullname: Реальное имя
+ created_at: Дата регистрации
+ user_current_sign_in_at: Последний раз заходил
+ game_type: Тип игры
+ rank: Место
+ points: Очки
+ wins: Побед
+ bnet_name: Никнейм в сети Battle.Net
+ bnet_server: Сервер
+ achievements: Очки достижений
+ synchronized_at: Последнее обновление
View
12 config/locales/ru.yml
@@ -110,4 +110,16 @@ ru:
forgot_password: Забыли пароль?
send_me_reset_password_instructions: Выслать мне инструкции по сбросу пароля
view_profile: Просмотр профайла
+ user_profile: "Профаил прользователя - %{user}"
+ common_info: Общая информация
+ battlenet_info: Battle.Net информация
+ game_stats: Статистика матчей
+ no_played_games_yet: Нет сыгранных матчей
+ bnet_servers:
+ eu: Европа
+ kr: "Корея"
+ us: "США"
+ tw: "Тайвань"
+ sea: "Южно-Центральная Азия"
+ reload: Обновить

0 comments on commit 8bdffba

Please sign in to comment.
Something went wrong with that request. Please try again.