Skip to content

Commit e37eb7d

Browse files
committed
more......
1 parent 6c9acb9 commit e37eb7d

29 files changed

+1057
-6
lines changed

app/controllers/application_controller.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class ApplicationController < ActionController::Base
22
protect_from_forgery
33

44
# before_filter :intercept_html_requests
5-
helper_method :current_user
5+
helper_method :current_user, :admin?, :superadmin?
66

77
# rescue_from CanCan::AccessDenied do |exception|
88
# head 401
@@ -25,4 +25,12 @@ def index
2525
def current_user
2626
@current_user ||= User.find(session[:user_id]) if session[:user_id]
2727
end
28+
29+
def admin?
30+
current_user.try :admin?
31+
end
32+
33+
def superadmin?
34+
current_user.try :superadmin?
35+
end
2836
end

app/inputs/collection_select_input.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class CollectionSelectInput < SimpleForm::Inputs::CollectionSelectInput
2+
def input_html_classes
3+
super.push('select2')
4+
end
5+
end

app/views/categories/_form.html.haml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.well
2+
= simple_form_for @category do |f|
3+
= f.input :name
4+
= f.association :parent
5+
= f.submit
6+
/ <div class='row'>
7+
/ <div class='span8'>
8+
/ <div class='well'>
9+
/ <form class='form-horizontal' name='categoryForm'>
10+
/ <fieldset>
11+
/ <legend>
12+
/ {{ formTitle() }}
13+
/ </legend>
14+
/ <control-group label='Name'>
15+
/ <input class='input-xlarge' id='name' ng-model='object.name' type='text' />
16+
/ </control-group>
17+
/ <control-group label='Parent'>
18+
/ <select class='input-xlarge' data-placeholder='category' ng-model='object.parent_id' ui-select2='{allowClear:true}'>
19+
/ <option value='' translate="sincatsup">(sin categoria superior)</option>
20+
/ <option ng-repeat='cat in categories' value='{{ cat.id }}'>{{ cat.fqn }}</option>
21+
/ </select>
22+
/ </control-group>
23+
/ </fieldset>
24+
/ <pre>{{ object | json }}</pre>
25+
/ <div class='form-actions'>
26+
/ <button class='btn btn-primary' ng-click='save(object)' type='submit' translate="guardar">Guardar</button>
27+
/ <a class='btn' href='#/categories' translate="cancelar">Cancelar</a>
28+
/ </div>
29+
/ </form>
30+
/ </div>
31+
/ </div>
32+
/ </div>
33+

app/views/categories/edit.html.haml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.page-header
2+
%h1
3+
Edit
4+
= @category.name
5+
6+
= render partial: "form"

app/views/categories/index.html.haml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
%table.table.table-hover.table-condensed
2+
%thead
3+
%tr
4+
%th{colspan: 10}
5+
.navbar
6+
.navbar-inner
7+
%ul.nav.pull-right
8+
%a.btn.btn-primary{href: "/categories/new"}
9+
= t "Nuevo servicio"
10+
%tr
11+
%th= t ".nombre"
12+
%tbody
13+
- @categories.each do |cat|
14+
%tr
15+
%td
16+
%a{href: "/categories/#{cat.id}"}= cat.fqn

app/views/categories/new.html.haml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
%h1= t ".new"
2+
= render partial: "form"

app/views/categories/show.html.haml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.well
2+
%h1= @category.name
3+
%dl
4+
%dt= t ".created_at"
5+
%dd= l @category.created_at
6+
%dt= t ".updated_at"
7+
%dd= l @category.updated_at
8+
- if @category.ancestors.present?
9+
%dt= t ".parent"
10+
%dd
11+
- @category.ancestors.reverse.each_with_index do |cat, idx|
12+
- unless idx.zero?
13+
= Category::FQN_SEPARATOR
14+
= link_to(cat, category_path(cat))
15+
- if @category.children.present?
16+
%dt= t ".children"
17+
%dd
18+
- @category.children.each_with_index do |cat, idx|
19+
- unless idx.zero?
20+
&mdash;
21+
= link_to(cat, category_path(cat))
22+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
!!! 5
2+
%html{lang: "en", "ng-app" => "APP"}
3+
%head
4+
%meta{charset: "utf-8"}
5+
%meta{"http-equiv" => "X-UA-Compatible", content: "IE=Edge,chrome=1"}
6+
%meta{name: "viewport", content: "width=device-width, initial-scale=1.0"}
7+
%title
8+
= yield :title
9+
= cdn :"lodash.js", "1.0.1", "lodash.min.js"
10+
= cdn :jquery, "1.9.1", "jquery.min.js"
11+
= cdn :jqueryui, "1.10.1", "jquery-ui.min.js"
12+
= cdn :select2, "3.3.0", "select2.min.js"
13+
= cdn :"twitter-bootstrap", "2.3.1", "js/bootstrap.min.js"
14+
= cdn :"bootstrap-datepicker", "1.0.0", "js/bootstrap-datepicker.js"
15+
= javascript_include_tag "application"
16+
= csrf_meta_tags
17+
= cdn :jqueryui, "1.10.1", "themes/base/jquery-ui.css"
18+
= cdn :select2, "3.3.0", "select2.css"
19+
= cdn :"twitter-bootstrap", "2.3.1", "css/bootstrap.no-icons.min.css"
20+
= cdn :"bootstrap-datepicker", "1.0.0", "css/datepicker.css"
21+
= cdn :"font-awesome", "3.0.2", "css/font-awesome.css"
22+
= stylesheet_link_tag "application", :media => "all"
23+
%link{href: "/favicon.ico", rel: "shortcut icon"}
24+
25+
%body
26+
.navbar.navbar-fixed-top.navbar-inverse
27+
.navbar-inner
28+
.container-fluid
29+
%a.brand{href: "/"} TimeOverflow
30+
.nav-collapse
31+
%ul.nav
32+
%li
33+
%a{href: "/organizations"}
34+
%i.icon-group
35+
= Organization.model_name.human(count: :many)
36+
%li
37+
%a{href: "/categories"}
38+
%i.icon-tags
39+
= Category.model_name.human.pluralize
40+
%li
41+
%a{href: "/users"}
42+
%i.icon-user
43+
= User.model_name.human.pluralize
44+
%ul.nav.pull-right
45+
%li
46+
- if current_user
47+
%a{href: "/sessions", data: {method: :delete}}
48+
Log out
49+
= current_user.email
50+
- else
51+
%a{href: "/sessions/new"} Log in
52+
53+
%form.navbar-search.pull-right
54+
%input.search-query.xxlarge{"type" => "text", "placeholder" => "Search", "ng-model" => "searchTerm"}
55+
56+
57+
.container-fluid
58+
.row-fluid
59+
.span12
60+
= yield
61+
62+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
= simple_form_for @organization do |f|
2+
= f.input :name
3+
= f.submit
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
%h1
2+
%i.icon-group.icon-border
3+
= t "edit"
4+
= @organization.name
5+
%hr
6+
= render partial: "form"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
%h1
2+
%i.icon-group.icon-border
3+
= t "organizations"
4+
%table.table.table-hover.table-condensed
5+
%thead
6+
%tr
7+
.navbar
8+
.navbar-inner
9+
%ul.nav.pull-right
10+
- if current_user.try(:superadmin?)
11+
%a.btn.btn-primary{href: '/organizations/new'}
12+
= t ".nueva organización"
13+
%tr
14+
%th= t ".nombre"
15+
%th= t ".member_count"
16+
%th
17+
%i.icon-hand-down
18+
Acciones
19+
%tbody
20+
- @organizations.each do |org|
21+
%tr
22+
%td
23+
= link_to(org.name, org)
24+
%td
25+
= org.users.count
26+
%td.hover-actions
27+
%a.action{href: organization_path(org)}
28+
%i.icon-eye-open
29+
= t ".ver"
30+
- if current_user.try(:admin?)
31+
%a.action{href: edit_organization_path(org)}
32+
%i.icon-pencil
33+
= t "edit"
34+
%a.action{href: organization_path(org), data: {method: :delete}}
35+
%i.icon-trash
36+
= t ".borrar"
37+

app/views/organizations/new.html.haml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
%h1
2+
%i.icon-group.icon-border
3+
= t "New organization"
4+
= render partial: "form"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
%h1
2+
%i.icon-group.icon-border
3+
= @organization.name
4+
5+
6+
%ul.nav.nav-pills
7+
%li
8+
%a{href: organizations_path}
9+
%i.icon-hand-left
10+
= t 'back'
11+
%li
12+
%a{href: edit_organization_path(@organization)}
13+
%i.icon-pencil
14+
= t "edit"
15+
%li
16+
%a{href: organization_path(@organization), data: {method: :DELETE, confirm: t("are_you_sure") }}
17+
%i.icon-trash
18+
= t "delete"
19+
20+
21+
%dl
22+
%dt= t ".created_at"
23+
%dd= l @organization.created_at
24+
%dt= t ".updated_at"
25+
%dd= l @organization.updated_at
26+
%dt= t ".reg_number_seq"
27+
%dd= @organization.reg_number_seq

app/views/sessions/new.html.haml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
%h1 Log in
2+
3+
= simple_form_for :user, url: sessions_path do |f|
4+
= f.input :email
5+
= f.input :password
6+
= f.button :submit

app/views/users/_user.json.jbuilder

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.page-header
2+
%h1
3+
%i.icon-key.icon-border
4+
= @user.username
5+
%small= t "change_password"
6+
7+
= simple_form_for @user do |f|
8+
= f.input :password
9+
= f.input :password_confirmation
10+
11+
= f.submit

app/views/users/edit.html.haml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.page-header
2+
%h1
3+
%i.icon-edit.icon-border
4+
= @user.username
5+
%small
6+
= t "edit"
7+
8+
= simple_form_for @user do |f|
9+
10+
= f.input :username
11+
= f.input :email
12+
- if current_user.try :superadmin?
13+
= f.association :organization
14+
= f.input :superadmin, hint: t(".superadmin_warning")
15+
- if current_user.try :admin?
16+
= f.input :admin, hint: t(".admin_warning")
17+
18+
= f.input :registration_date, as: :string, input_html: {type: :date}
19+
= f.input :date_of_birth, as: :string, input_html: {type: :date}
20+
= f.input :identity_document
21+
= f.input :phone
22+
= f.input :alt_phone
23+
24+
= f.association :categories, as: :check_boxes
25+
26+
= f.submit

app/views/users/index.html.haml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.page-header
2+
%h1
3+
%i.icon-user.icon-border
4+
= User.model_name.human.pluralize
5+
6+
%table.table.table-hover.table-condensed
7+
%thead
8+
%tr
9+
.navbar
10+
.navbar-inner
11+
%ul.nav.pull-right
12+
- if admin?
13+
%a.btn.btn-primary{href: new_user_path}
14+
= t ".create"
15+
%tr
16+
- if superadmin?
17+
%th= User.human_attribute_name(:organization)
18+
%th= User.human_attribute_name(:registration_number)
19+
%th= User.human_attribute_name(:username)
20+
%th= User.human_attribute_name(:email)
21+
%th= User.human_attribute_name(:phone)
22+
%th= User.human_attribute_name(:alt_phone)
23+
24+
%th
25+
%i.icon-hand-down
26+
Acciones
27+
%tbody
28+
- @users.each do |user|
29+
%tr
30+
- if superadmin?
31+
%td= link_to(user.organization, user.organization)
32+
%td= user.registration_number
33+
%td= link_to(user, user)
34+
%td= user.email
35+
%td= user.phone
36+
%td= user.alt_phone
37+
%td.hover-actions
38+
%a.action{href: user_path(user)}
39+
%i.icon-eye-open
40+
= t ".ver"
41+
- if admin?
42+
%a.action{href: edit_user_path(user)}
43+
%i.icon-pencil
44+
= t "edit"
45+
%a.action{href: user_path(user), data: {method: :delete}}
46+
%i.icon-trash
47+
= t ".borrar"
48+

app/views/users/index.json.jbuilder

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/views/users/new.html.haml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.page-header
2+
%h1
3+
%i.icon-user.icon-border
4+
New user
5+
6+
= simple_form_for @user do |f|
7+
8+
= f.input :username
9+
= f.input :email
10+
- if superadmin?
11+
= f.association :organization
12+
= f.input :superadmin, hint: t(".superadmin_warning")
13+
- if admin?
14+
= f.input :admin, hint: t(".admin_warning")
15+
16+
= f.input :password
17+
= f.input :password_confirmation
18+
= f.submit

0 commit comments

Comments
 (0)