Skip to content

Commit

Permalink
Added links to first page and logout
Browse files Browse the repository at this point in the history
  • Loading branch information
pbalduino committed Oct 11, 2011
1 parent 4906ec9 commit eb86706
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 93 deletions.
8 changes: 8 additions & 0 deletions app/assets/stylesheets/application.sass
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@ table.list
padding: 0.2em

tbody
td:hover
background-color: darken($bgcolor, 6%)

td
background-color: darken($bgcolor, 3%)
padding: 0.2em

a
text-decoration: none
color: $color

#new_ticket
margin-top: 2em

Expand Down Expand Up @@ -68,3 +75,4 @@ a.pretty-button:active
#tickets label
width: 100px
float: left

5 changes: 5 additions & 0 deletions app/controllers/tickets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ def create
flash[:notice] = 'Ticket incluido'

redirect_to root_url
end

def show
@ticket = Ticket.where('id = ? and user_id = ?', params[:id], current_user.id).first
@comments = Comment.where('ticket_id = ?', @ticket.id) if @ticket
puts @ticket
end

end
Expand Down
2 changes: 2 additions & 0 deletions app/models/ticket.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Ticket < ActiveRecord::Base
belongs_to :user

Status = [['Aberto', 1],
['Em andamento', 2],
['Fechado', 3]]
Expand Down
26 changes: 12 additions & 14 deletions app/views/devise/registrations/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
%h2 Sign up
%h2 Cadastrar usuário
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
= devise_error_messages!
%div
= f.label :email
%br/
= f.email_field :email
%div
= f.label :password
%br/
= f.password_field :password
%div
= f.label :password_confirmation
%br/
= f.password_field :password_confirmation
%div= f.submit "Sign up"
%p
= f.label :email, 'Login: '
= f.email_field :email, :placeholder => 'informe um email válido', :maxlength => 50, :size => 50
%p
= f.label :password, 'Senha: '
= f.password_field :password, :placeholder => 'com mais de seis caracteres', :maxlength => 30, :size => 30
%p
= f.label :password_confirmation, 'Confirme a senha: '
= f.password_field :password_confirmation, :placeholder => 'repita sua senha', :maxlength => 30, :size => 30
%p= f.submit "Cadastrar"
= render :partial => "devise/shared/links"

21 changes: 8 additions & 13 deletions app/views/devise/sessions/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
%h2 Entrar no sistema
= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
%div
= f.label :email
%br/
= f.email_field :email
%div
= f.label :password
%br/
= f.password_field :password
- if devise_mapping.rememberable?
%div
= f.check_box :remember_me
= f.label :remember_me
%div= f.submit "Sign in"
%p
= f.label :email, 'Login:', :maxlength => 50, :size => 50
= f.email_field :email, :placeholder => 'informe seu email'
%p
= f.label :password, 'Senha: ', :maxlength => 30, :size => 30
= f.password_field :password, :placeholder => 'informe sua senha'
%div= f.submit "Entrar"
= render :partial => "devise/shared/links"

19 changes: 3 additions & 16 deletions app/views/devise/shared/_links.haml
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
- if controller_name != 'sessions'
= link_to "Sign in", new_session_path(resource_name)
= link_to "Entrar", new_session_path(resource_name)
%br/
- if devise_mapping.registerable? && controller_name != 'registrations'
= link_to "Sign up", new_registration_path(resource_name)
%br/
- if devise_mapping.recoverable? && controller_name != 'passwords'
= link_to "Forgot your password?", new_password_path(resource_name)
%br/
- if devise_mapping.confirmable? && controller_name != 'confirmations'
= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name)
%br/
- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name)
%br/
- if devise_mapping.omniauthable?
- resource_class.omniauth_providers.each do |provider|
= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider)
%br/
= link_to "Cadastre-se", new_registration_path(resource_name)

6 changes: 3 additions & 3 deletions app/views/tickets/_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
- @tickets.each do |ticket|
%tr
%td{:width => 15}
="#{ticket.created_at.strftime('%d/%m/%Y') if ticket.created_at}"
=link_to "#{ticket.created_at.strftime('%d/%m/%Y') if ticket.created_at}", ticket
%td
=ticket.description
=link_to ticket.description, ticket
%td{:width => 120}
=Ticket::Status[ticket.status - 1][0]
=link_to Ticket::Status[ticket.status - 1][0], ticket

22 changes: 22 additions & 0 deletions app/views/tickets/_view_ticket.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
%p
%label='Data: '
%b=ticket.created_at
%p
%label='Responsável: '
%b=ticket.user.email
%p
%label='Status: '
%b=Ticket::Status[ticket.status - 0][0]
%p
Histórico:
%ul
-@comments.each do |comment|
%li
%b=comment.created_at.strftime('%d/%m/%Y %H:%M:%S')
%br
=comment.comment
%p
=link_to 'Voltar', tickets_url
=' | '
=link_to 'Sair', destroy_user_session_url

2 changes: 2 additions & 0 deletions app/views/tickets/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
=render :partial => 'list'
#new_ticket
=link_to 'Cadastrar novo ticket', new_ticket_url, :class => 'pretty-button'
%p
=link_to 'Sair', destroy_user_session_url

4 changes: 4 additions & 0 deletions app/views/tickets/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
=text_area_tag :comment, 'whatever', :size => '24x6'
%p
=form.submit 'Gravar'
%p
=link_to 'Voltar', tickets_url
=' | '
=link_to 'Sair', destroy_user_session_url

7 changes: 7 additions & 0 deletions app/views/tickets/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
%h2 Visualizar ticket

- if @ticket
= render :partial => 'view_ticket', :locals => {:ticket => @ticket}
- else
Ticket não encontrado

3 changes: 2 additions & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
# config.navigational_formats = [:"*/*", "*/*", :html]

# The default HTTP method used to sign out a resource. Default is :delete.
config.sign_out_via = :delete
# config.sign_out_via = :delete

# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
Expand All @@ -208,3 +208,4 @@
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
# end
end

92 changes: 46 additions & 46 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20111007020150) do

create_table "comments", :force => true do |t|
t.integer "ticket_id"
t.text "comment"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "tickets", :force => true do |t|
t.integer "user_id"
t.string "description"
t.integer "status"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "password_salt"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "users", ["email"], :name => "index_users_on_email", :unique => true

end
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20111007020150) do

create_table "comments", :force => true do |t|
t.integer "ticket_id"
t.text "comment"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "tickets", :force => true do |t|
t.integer "user_id"
t.string "description"
t.integer "status"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "password_salt"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "users", ["email"], :name => "index_users_on_email", :unique => true

end

0 comments on commit eb86706

Please sign in to comment.