Skip to content

Commit

Permalink
Adição de editar perfil
Browse files Browse the repository at this point in the history
  • Loading branch information
daniloisr committed May 18, 2012
1 parent a167800 commit 414e949
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 28 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/logs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def index
day, month, year = params[:date].split('-')
date = DateTime.new(year.to_i, month.to_i, day.to_i)
condition = ['created_at > ? AND created_at < ?', date.beginning_of_day, date.end_of_day]
@logs = Log.where(condition).page(params[:page]).per(4)
@logs = Log.where(condition).page(params[:page]).per(10)
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/admin/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Admin::ProjectsController < ApplicationController
before_filter :find_users_by_param, :only => [:create, :update]

def index
@projects = ::Project.paginate(:page => params[:page])
@projects = ::Project.page(params[:page]).per(10)
end

def show
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Admin::UsersController < ApplicationController
before_filter :authenticate!, :only_admin!

def index
@users = User.paginate(:page => params[:page])
@users = User.page(params[:page]).per(10)
end

def show
Expand Down
22 changes: 12 additions & 10 deletions app/models/permission.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# encoding: utf-8
class Permission
@@defaults = {
gerente: [
{ name: 'Gerenciar Projetos', controller: 'projects', actions: 'all' },
{ name: 'Gerenciar Usuários', controller: 'users', actions: 'all' },
{ name: 'Gerenciar Ips', controller: 'ips', actions: 'all' }
],
comum: [
{ name: 'Visualizer Projeto', controller: 'projects', actions: 'show' },
{ name: 'Visualizar Usuário', controller: 'users', actions: 'show' }
]
}
gerente: [
{ name: 'Gerenciar Projetos', controller: 'projects', actions: 'all' },
{ name: 'Gerenciar Usuários', controller: 'users', actions: 'all' },
{ name: 'Gerenciar Ips', controller: 'ips', actions: 'all' }
],
comum: [
{ name: 'Visualizer Projeto', controller: 'projects', actions: 'show' },
{ name: 'Visualizar Usuário', controller: 'users', actions: 'show' }
]
}
def self.defaults
@@defaults
end
end
2 changes: 1 addition & 1 deletion app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def project_path
@project_name ||= sanitize_string_to_folder_name(self.project.name)
@repository_name ||= sanitize_string_to_folder_name(self.name)

REPOS_PATH.join(@project_name, @repository_name)
REPOS_PATH.join(@project_name, @repository_name).to_s
end


Expand Down
5 changes: 3 additions & 2 deletions app/models/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
class Role < ActiveRecord::Base
has_many :users

attr_accessible :permissions
attr_accessible :description, :name
attr_accessor :permissions

validates :name,
:presence => :true,
Expand All @@ -11,7 +12,7 @@ class Role < ActiveRecord::Base

def self.defaults
gerente = Role.find_or_create_by_name('Gerente', :description => 'Gerencia o sistema')
gerente.permissions = Permission.defaults[:gerente]
gerente.permissions = Permission::defaults[:gerente]

comum = Role.find_or_create_by_name('Usuário Comum', :description => 'Usuário comum do sistema')
comum.permissions = Permission.defaults[:comum]
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/users/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
</div>
<div class="field">
<%= f.label :password %>
<%= f.text_field :password %>
<%= f.password_field :password %>
</div>
<div class="field">
<%= f.label :password_confirmation %>
<%= f.text_field :password_confirmation %>
<%= f.password_field :password_confirmation %>
</div>
<div class="field">
<%= f.label :admin %>
Expand Down
3 changes: 2 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

<ul nav nav-list>
<% if current_user %>
<%= content_tag :li, link_to(t('logout'), logout_path, :method => :delete) %>
<%= content_tag :li, link_to(t('.logout'), logout_path, :method => :delete) %>
<%= content_tag :li, link_to(t('.editaccount'), editaccount_path) %>
<% else %>
<%= content_tag :li, link_to(t('.register'), new_user_path) if setting(:allow_register) == 'true' %>
<%= content_tag :li, link_to(t('.login'), login_path) %>
Expand Down
35 changes: 33 additions & 2 deletions app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
<h1>Users#edit</h1>
<p>Find me in app/views/users/edit.html.erb</p>
<h1><%= t('.title') %></h1>

<%= form_for(@user) do |f| %>
<% if @user.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>

<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= f.label :name %>
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :password %>
<%= f.password_field :password %>
</div>
<div class="field">
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation %>
</div>

<div class="actions">
<%= f.submit %>
</div>

<% end %>
4 changes: 2 additions & 2 deletions app/views/users/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
</div>
<div class="field">
<%= f.label :password %>
<%= f.text_field :password %>
<%= f.password_field :password %>
</div>
<div class="field">
<%= f.label :password_confirmation %>
<%= f.text_field :password_confirmation %>
<%= f.password_field :password_confirmation %>
</div>
<div class="actions">
<%= f.submit %>
Expand Down
3 changes: 2 additions & 1 deletion config/locales/views/defaults/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ pt-BR:
ips: IPs
logs: Logs
settings: Configurações
editaccount: Editar seus Dados
views:
pagination:
first: "&laquo;"
last: "&raquo;"
previous: "&lsaquo;"
next: "&rsaquo;"
truncate: "..."
truncate: "..."
4 changes: 4 additions & 0 deletions config/locales/views/users/pt-BR.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
pt-BR:
users:
new:
title: Cadastro de Usuário
edit:
title: Editar dados pessoais
create:
successfully_create: 'Sua conta foi criada com sucesso!'
update:
Expand Down
8 changes: 4 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@


# Users routes
resources :users, :except => [:destroy], :path_names => {
:new => :signup,
:edit => :editaccount
}
get 'editaccount' => 'users#edit'
resources :users, :except => [:destroy, :edit], :path_names => {
:new => :signup } do
end


# Projects routes
Expand Down

0 comments on commit 414e949

Please sign in to comment.