Skip to content

Commit

Permalink
Organiznado locales/interface
Browse files Browse the repository at this point in the history
  • Loading branch information
daniloisr committed Jun 4, 2012
1 parent 414e949 commit 58e4718
Show file tree
Hide file tree
Showing 22 changed files with 322 additions and 156 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ gem 'sqlite3'

gem 'bootstrap-sass', '~> 2.0.3'
gem 'kaminari'
gem 'simple_form'

# Gems used only for assets and not required
# in production environments by default.
Expand Down
5 changes: 4 additions & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ Um Projeto do Cercomp...
Twitter Bootstrap SCSS
http://railsapps.github.com/twitter-bootstrap-rails.html

Simple-form c/ Bootstrap
https://github.com/plataformatec/simple_form

Alguma documentação dos bindings SVN
http://www.cs.toronto.edu/~james/svn/ruby_docs.html

Datepicker p/ bootstrap
http://www.eyecon.ro/bootstrap-datepicker/
http://www.eyecon.ro/bootstrap-datepicker/
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def can?(action, controller)
return false if current_user.role.nil?

current_user.role.permissions.each do |permission|
if permission.controller == controller and permission.actions.split.include?(action)
if permission[:controller] == controller and permission[:actions].split.include?(action)
return true
break
end
Expand Down
6 changes: 3 additions & 3 deletions app/models/permission.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# encoding: utf-8
class Permission
@@defaults = {
gerente: [
'Gerente' => [
{ name: 'Gerenciar Projetos', controller: 'projects', actions: 'all' },
{ name: 'Gerenciar Usuários', controller: 'users', actions: 'all' },
{ name: 'Gerenciar Ips', controller: 'ips', actions: 'all' }
{ name: 'Gerenciar Ips', controller: 'ips', actions: 'all' }
],
comum: [
'Usuário Comum' => [
{ name: 'Visualizer Projeto', controller: 'projects', actions: 'show' },
{ name: 'Visualizar Usuário', controller: 'users', actions: 'show' }
]
Expand Down
8 changes: 4 additions & 4 deletions app/models/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class Role < ActiveRecord::Base
:uniqueness => true,
:length => {:in => 3..32}

def permissions
return Permission::defaults[name]
end

def self.defaults
gerente = Role.find_or_create_by_name('Gerente', :description => 'Gerencia o sistema')
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]

{ gerente: gerente, comum: comum }
end
end
26 changes: 15 additions & 11 deletions app/views/admin/projects/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
<h1>Listing projects</h1>

<table>
<table class="table table-striped">
<tr>
<th>Name</th>
<th>Description</th>
<th></th>
<th></th>
<th></th>
<th><%= t('name', :scope => 'activerecord.attributes.project') %></th>
<th><%= t('description', :scope => 'activerecord.attributes.project') %></th>
<th colspan="2"><%= t('actions', :scope => 'application') %></th>
</tr>

<% @projects.each do |project| %>
<tr>
<tr data-url="<%= url_for([:admin, project]) %>" style="cursor: pointer">
<td><%= project.name %></td>
<td><%= project.description %></td>
<td><%= link_to 'Show', [:admin, project] %></td>
<td><%= link_to 'Edit', edit_admin_project_path(project) %></td>
<td><%= link_to 'Destroy', [:admin, project], confirm: 'Are you sure?', method: :delete %></td>
<td><%= link_to t('edit', :scope => 'application'), edit_admin_project_path(project) %></td>
<td><%= link_to t('destroy', :scope => 'application'),
[:admin, project], confirm: 'Are you sure?', method: :delete %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New Project', new_admin_project_path %>
<script type="text/javascript">
$('tr').dblclick(function() {
window.location.href = $(this).data('url');
});
</script>

<%= link_to t('new_obj', :scope => 'application', :obj => t('activerecord.models.project')), new_admin_project_path %>
53 changes: 0 additions & 53 deletions app/views/admin/users/show.html.erb

This file was deleted.

12 changes: 5 additions & 7 deletions app/views/projects/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<h1>Listing projects</h1>
<h1><%= t('.title') %></h1>

<table>
<table class="table table-striped">
<tr>
<th>Name</th>
<th>Description</th>
<th></th>
<th></th>
<th></th>
<th><%= t('name', :scope => 'activerecord.attributes.project') %></th>
<th><%= t('description', :scope => 'activerecord.attributes.project') %></th>
<th><%= t('actions', :scope => 'application') %></th>
</tr>

<% @projects.each do |project| %>
Expand Down
28 changes: 16 additions & 12 deletions app/views/session/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<h1>Login</h1>
<%= form_tag login_path do %>
<p>
<%= label_tag :login %>
<%= text_field_tag :login %>
</p>
<%= form_tag login_path, :class => 'form-horizontal' do %>
<div class="control-group">
<%= label_tag :login, t('.login'), :class => 'control-label' %>
<div class="controls">
<%= text_field_tag :login %>
</div>
</div>

<p>
<%= label_tag :password %>
<%= password_field_tag :password %>
</p>
<div class="control-group">
<%= label_tag :password, t('.password'), :class => 'control-label' %>
<div class="controls">
<%= password_field_tag :password %>
</div>
</div>

<p>
<%= submit_tag :login %>
</p>
<div class="form-actions">
<%= submit_tag :login, :class => 'btn btn-primary' %>
</div>
<% end %>
13 changes: 13 additions & 0 deletions app/views/shared/_form_errors.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<% if object.errors.any? %>
<div id="error_explanation">
<% # TODO internacionalização aki %>
<h2><%= pluralize(object.errors.count, "erro") %> impediram esse objeto de ser salvo:</h2>
<ul>
<% object.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

36 changes: 8 additions & 28 deletions app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,33 +1,13 @@
<h1><%= t('.title') %></h1>
<br>

<%= 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>
<%= simple_form_for(@user, :html => { :class => 'form-horizontal' } ) do |f| %>

<%= f.input :name %>
<%= f.input :password %>
<%= f.input :password_confirmation %>

<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 class="form-actions">
<%= f.button :submit, :class => 'btn-primary' %>
</div>

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

<% end %>
13 changes: 11 additions & 2 deletions app/views/users/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
<h1><%= t('.title') %></h1>

<table>
<table class="table table-striped">
<tr>
<th>Nome</th>
<th>Papel</th>
<th>Email</th>
</tr>

<% @users.each do |user| %>
<tr>
<% attrs = "data-url='#{url_for(edit_admin_user_path(user))}' style='cursor: pointer'" if current_user.admin? %>
<tr <%= attrs %>>
<td><%= user.name %></td>
<td><%= user.role.try(:name) %></td>
<td><%= user.email %></td>
</tr>
<% end %>
</table>

<% if current_user.admin? %>
<script type="text/javascript">
$('tr').click(function() {
window.location.href = $(this).data('url');
});
</script>
<% end %>
41 changes: 8 additions & 33 deletions app/views/users/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,39 +1,14 @@
<h1>Cadastro de Usuário</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>
<%= simple_form_for(@user, :html => {:class => 'form-horizontal'}) do |f| %>

<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<%= f.input :login %>
<%= f.input :name %>
<%= f.input :email %>
<%= f.input :password %>
<%= f.input :password_confirmation %>

<div class="field">
<%= f.label :login %>
<%= f.text_field :login %>
</div>
<div class="field">
<%= f.label :name %>
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :email %>
<%= f.text_field :email %>
</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 class="form-actions">
<%= f.button :submit, :class => 'btn-primary' %>
</div>
<% end %>
Loading

0 comments on commit 58e4718

Please sign in to comment.