diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb new file mode 100644 index 0000000..f9f86e8 --- /dev/null +++ b/app/controllers/calendars_controller.rb @@ -0,0 +1,6 @@ +class CalendarsController < ApplicationController + def show + @users_by_availability = User.by_availability + @weekdays = %w(monday tuesday wednesday thursday friday saturday sunday) + end +end diff --git a/app/controllers/my_account_controller.rb b/app/controllers/my_accounts_controller.rb similarity index 78% rename from app/controllers/my_account_controller.rb rename to app/controllers/my_accounts_controller.rb index f120b5e..3c44088 100644 --- a/app/controllers/my_account_controller.rb +++ b/app/controllers/my_accounts_controller.rb @@ -1,6 +1,6 @@ -class MyAccountController < ApplicationController +class MyAccountsController < ApplicationController - def index + def show @user = current_user @weekdays = %w(monday tuesday wednesday thursday friday saturday sunday) diff --git a/app/helpers/calendar_helper.rb b/app/helpers/calendar_helper.rb new file mode 100644 index 0000000..72ade11 --- /dev/null +++ b/app/helpers/calendar_helper.rb @@ -0,0 +1,2 @@ +module CalendarHelper +end diff --git a/app/models/user.rb b/app/models/user.rb index 8cb72a0..caefbfd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,6 +16,20 @@ class User < ActiveRecord::Base end end + + def self.by_availability + @by_availability ||= {} + + weekdays = %w(monday tuesday wednesday thursday friday saturday sunday) + (10..22).each do |hour| + weekdays.each do |day| + @by_availability["#{day}_#{hour}"] = self.where("#{day}_#{hour}" => true) + end + end + + return @by_availability + end + def has_name_and_phone? name.present? && phone.present? end diff --git a/app/views/calendars/show.html.haml b/app/views/calendars/show.html.haml new file mode 100644 index 0000000..3d20498 --- /dev/null +++ b/app/views/calendars/show.html.haml @@ -0,0 +1,32 @@ +.page-header + %h1 Calendar + +%table.table.table-striped + %thead + %tr + %td   + - @weekdays.each do |day| + %th= day + %tbody + - (10..22).each do |hour| + %tr + %th= hour + - @weekdays.each do |day| + %td + - @users_by_availability["#{day}_#{hour}"].each do |user| + %i{:class => "icon-user", :title => user.name} + + - if @users_by_availability["#{day}_#{hour}"].count > 0 + .modal.hide.fade.in{:style => "display: none; ", :id => "#{day}_#{hour}"} + .modal-header + %a.close{"data-dismiss" => "modal"} × + %h3= "#{day} at #{hour}" + .modal-body + %p= @users_by_availability["#{day}_#{hour}"].collect(&:name).to_sentence + .modal-footer + %a.btn.btn-success{:href => "#"} Let's play + %a.btn{"data-dismiss" => "modal", :href => "#"} Close + + + %a{"data-toggle" => "modal", :href => "##{day}_#{hour}"} + %i{:class => "icon-plus"} \ No newline at end of file diff --git a/app/views/devise/confirmations/new.html.haml b/app/views/devise/confirmations/new.html.haml new file mode 100644 index 0000000..88c6373 --- /dev/null +++ b/app/views/devise/confirmations/new.html.haml @@ -0,0 +1,9 @@ +%h2 Resend confirmation instructions += form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| + = devise_error_messages! + %div + = f.label :email + %br/ + = f.email_field :email, :autofocus => true + %div= f.submit "Resend confirmation instructions" += render "devise/shared/links" diff --git a/app/views/devise/mailer/confirmation_instructions.html.haml b/app/views/devise/mailer/confirmation_instructions.html.haml new file mode 100644 index 0000000..eeab62b --- /dev/null +++ b/app/views/devise/mailer/confirmation_instructions.html.haml @@ -0,0 +1,4 @@ +%p + Welcome #{@email}! +%p You can confirm your account email through the link below: +%p= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) diff --git a/app/views/devise/mailer/reset_password_instructions.html.haml b/app/views/devise/mailer/reset_password_instructions.html.haml new file mode 100644 index 0000000..bc9e196 --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.html.haml @@ -0,0 +1,6 @@ +%p + Hello #{@resource.email}! +%p Someone has requested a link to change your password. You can do this through the link below. +%p= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) +%p If you didn't request this, please ignore this email. +%p Your password won't change until you access the link above and create a new one. diff --git a/app/views/devise/mailer/unlock_instructions.html.haml b/app/views/devise/mailer/unlock_instructions.html.haml new file mode 100644 index 0000000..72f6a0b --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.html.haml @@ -0,0 +1,5 @@ +%p + Hello #{@resource.email}! +%p Your account has been locked due to an excessive number of unsuccessful sign in attempts. +%p Click the link below to unlock your account: +%p= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) diff --git a/app/views/devise/passwords/edit.html.haml b/app/views/devise/passwords/edit.html.haml new file mode 100644 index 0000000..8515688 --- /dev/null +++ b/app/views/devise/passwords/edit.html.haml @@ -0,0 +1,14 @@ +%h2 Change your password += form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| + = devise_error_messages! + = f.hidden_field :reset_password_token + %div + = f.label :password, "New password" + %br/ + = f.password_field :password, :autofocus => true + %div + = f.label :password_confirmation, "Confirm new password" + %br/ + = f.password_field :password_confirmation + %div= f.submit "Change my password" += render "devise/shared/links" diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml new file mode 100644 index 0000000..591033b --- /dev/null +++ b/app/views/devise/passwords/new.html.haml @@ -0,0 +1,9 @@ +%h2 Forgot your password? += form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| + = devise_error_messages! + %div + = f.label :email + %br/ + = f.email_field :email, :autofocus => true + %div= f.submit "Send me reset password instructions" += render "devise/shared/links" diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml new file mode 100644 index 0000000..7449114 --- /dev/null +++ b/app/views/devise/registrations/edit.html.haml @@ -0,0 +1,30 @@ +%h2 + Edit #{resource_name.to_s.humanize} += form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| + = devise_error_messages! + %div + = f.label :email + %br/ + = f.email_field :email, :autofocus => true + - if devise_mapping.confirmable? && resource.pending_reconfirmation? + %div + Currently waiting confirmation for: #{resource.unconfirmed_email} + %div + = f.label :password + %i (leave blank if you don't want to change it) + %br/ + = f.password_field :password, :autocomplete => "off" + %div + = f.label :password_confirmation + %br/ + = f.password_field :password_confirmation + %div + = f.label :current_password + %i (we need your current password to confirm your changes) + %br/ + = f.password_field :current_password + %div= f.submit "Update" +%h3 Cancel my account +%p + Unhappy? #{button_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete} += link_to "Back", :back diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml new file mode 100644 index 0000000..4866d60 --- /dev/null +++ b/app/views/devise/registrations/new.html.haml @@ -0,0 +1,25 @@ +%h2 Sign up += form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| + = devise_error_messages! + %div + = f.label :name + %br/ + = f.text_field :name, :autofocus => true + %div + = f.label :phone + %br/ + = f.text_field :phone + %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" += render "devise/shared/links" diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml new file mode 100644 index 0000000..0746ee8 --- /dev/null +++ b/app/views/devise/sessions/new.html.haml @@ -0,0 +1,16 @@ +%h2 Sign in += form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| + %div + = f.label :email + %br/ + = f.email_field :email, :autofocus => true + %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" += render "devise/shared/links" diff --git a/app/views/devise/shared/_links.haml b/app/views/devise/shared/_links.haml new file mode 100644 index 0000000..35d07ec --- /dev/null +++ b/app/views/devise/shared/_links.haml @@ -0,0 +1,19 @@ +- if controller_name != 'sessions' + = link_to "Sign in", 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/ diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.html.haml new file mode 100644 index 0000000..d3c87d0 --- /dev/null +++ b/app/views/devise/unlocks/new.html.haml @@ -0,0 +1,9 @@ +%h2 Resend unlock instructions += form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| + = devise_error_messages! + %div + = f.label :email + %br/ + = f.email_field :email, :autofocus => true + %div= f.submit "Resend unlock instructions" += render "devise/shared/links" diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 15b2754..c2c2d89 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -25,13 +25,14 @@ %span.icon-bar %span.icon-bar %span.icon-bar - %a.brand(href="/") Padel + %a.brand Padel .container.nav-collapse - if user_signed_in? %ul.nav.pull-right %li= link_to t('devise.links.sign_out'), destroy_user_session_path, :method => :delete %ul.nav - %li= link_to "My account", "/" + %li= link_to "My account", my_account_path + %li= link_to "Calendar", calendar_path .container-fluid diff --git a/app/views/my_account/index.html.haml b/app/views/my_accounts/show.html.haml similarity index 96% rename from app/views/my_account/index.html.haml rename to app/views/my_accounts/show.html.haml index 2c88491..d352103 100644 --- a/app/views/my_account/index.html.haml +++ b/app/views/my_accounts/show.html.haml @@ -12,7 +12,9 @@ %b Email: = @user.email -%h2 My week +.page-header + %h2 My week + .row .span9 diff --git a/config/routes.rb b/config/routes.rb index 6c1dd99..d00704c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,9 +1,13 @@ Padel::Application.routes.draw do + resource :calendar, only: [:show] + + resource :my_account, only: [:show] + resources :users, only: [:update] devise_for :users - root to: 'my_account#index' + root to: 'my_accounts#show' # The priority is based upon order of creation: # first created -> highest priority. diff --git a/test/functional/calendar_controller_test.rb b/test/functional/calendar_controller_test.rb new file mode 100644 index 0000000..796f99d --- /dev/null +++ b/test/functional/calendar_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class CalendarControllerTest < ActionController::TestCase + test "should get show" do + get :show + assert_response :success + end + +end diff --git a/test/unit/helpers/calendar_helper_test.rb b/test/unit/helpers/calendar_helper_test.rb new file mode 100644 index 0000000..2df0c6f --- /dev/null +++ b/test/unit/helpers/calendar_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class CalendarHelperTest < ActionView::TestCase +end