mirror of
https://github.com/fspc/BikeShed-1.git
synced 2026-09-16 08:31:36 -04:00
git init
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
@@ -0,0 +1,16 @@
|
||||
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||
// listed below.
|
||||
//
|
||||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
||||
//
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
||||
// GO AFTER THE REQUIRES BELOW.
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require twitter/bootstrap
|
||||
//= require_tree .
|
||||
@@ -0,0 +1,4 @@
|
||||
jQuery ->
|
||||
$("a[rel=popover]").popover()
|
||||
$(".tooltip").tooltip()
|
||||
$("a[rel=tooltip]").tooltip()
|
||||
@@ -0,0 +1,15 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
||||
jQuery ->
|
||||
$('form').on 'click', '.remove_fields', (event) ->
|
||||
$(this).prev('input[type=hidden]').val('1')
|
||||
$(this).closest('fieldset').hide()
|
||||
event.preventDefault()
|
||||
|
||||
$('form').on 'click', '.add_fields', (event) ->
|
||||
time = new Date().getTime()
|
||||
regexp = new RegExp($(this).data('id'), 'g')
|
||||
$(this).before($(this).data('fields').replace(regexp, time))
|
||||
event.preventDefault()
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||
* listed below.
|
||||
*
|
||||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
||||
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
||||
*
|
||||
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
||||
* compiled file, but it's generally better to create a new file per style scope.
|
||||
*
|
||||
*= require_self
|
||||
*= require_tree .
|
||||
*/
|
||||
@@ -0,0 +1,17 @@
|
||||
@import "twitter/bootstrap/bootstrap";
|
||||
@import "twitter/bootstrap/responsive";
|
||||
|
||||
// Set the correct sprite paths
|
||||
@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
|
||||
@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
|
||||
|
||||
// Your custom LESS stylesheets goes here
|
||||
//
|
||||
// Since bootstrap was imported above you have access to its mixins which
|
||||
// you may use and inherit here
|
||||
//
|
||||
// If you'd like to override bootstrap's own variables, you can do so here as well
|
||||
// See http://twitter.github.com/bootstrap/less.html for their names and documentation
|
||||
//
|
||||
// Example:
|
||||
// @linkColor: #ff0000;
|
||||
@@ -0,0 +1,3 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
class AuthenticatedController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class SiteController < ApplicationController
|
||||
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,36 @@
|
||||
class TeamsController < AuthenticatedController
|
||||
expose(:team) do
|
||||
if params[:id]
|
||||
Team.find(params[:id])
|
||||
elsif params[:team]
|
||||
Team.new(params[:team])
|
||||
else
|
||||
Team.new(:max_members => 16)
|
||||
end
|
||||
end
|
||||
|
||||
expose(:teams) { Team.order('lower(name)').paginate(:page => params[:page]) }
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
team.captain = current_user
|
||||
if team.save
|
||||
redirect_to teams_url
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def join
|
||||
current_user.teams << team
|
||||
redirect_to team
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
module ApplicationHelper
|
||||
def link_to_add_fields(name, f, association)
|
||||
new_object = f.object.send(association).klass.new
|
||||
id = new_object.object_id
|
||||
fields = f.fields_for(association, new_object, child_index: id) do |builder|
|
||||
render(association.to_s.singularize + "_fields", f: builder)
|
||||
end
|
||||
link_to(name, '#', id: "add_#{association.to_s.singularize}" , class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
class Team < ActiveRecord::Base
|
||||
attr_accessible :name, :max_members, :private_team
|
||||
|
||||
belongs_to :captain, :class_name => 'User'
|
||||
has_many :team_memberships
|
||||
has_many :members, :through => :team_memberships, :source => :user
|
||||
|
||||
validates :name, :presence => true, :uniqueness => true, :length => { :minimum => 3 }
|
||||
validates :max_members, :presence => true, :numericality => { :only_integer => true, :greater_than => 0 }
|
||||
validates :captain, :presence => true
|
||||
|
||||
self.per_page = 15
|
||||
|
||||
def to_s
|
||||
"#{name}#{private_team? ? '*' : ''}"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
class TeamMembership < ActiveRecord::Base
|
||||
belongs_to :team
|
||||
belongs_to :user
|
||||
|
||||
validates :user, :presence => true
|
||||
validates :team, :presence => true
|
||||
validates :user_id, :uniqueness => { :scope => :team_id }
|
||||
validate :no_captains_allowed
|
||||
|
||||
|
||||
private
|
||||
|
||||
def no_captains_allowed
|
||||
if user.present? && team.present? && team.captain == user
|
||||
errors.add(:user, "Captain is already a member.")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
class User < ActiveRecord::Base
|
||||
# Include default devise modules. Others available are:
|
||||
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable, :lockable #TODO ,:confirmable
|
||||
|
||||
# Setup accessible (or protected) attributes for your model
|
||||
attr_accessible :email, :password, :password_confirmation, :remember_me,
|
||||
:first_name, :last_name, :nickname
|
||||
|
||||
validates :first_name, :presence => true
|
||||
validates :last_name, :presence => true
|
||||
|
||||
def to_s
|
||||
"#{first_name} #{last_name}"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,25 @@
|
||||
<%- if controller_name != 'sessions' %>
|
||||
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
||||
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
|
||||
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
||||
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- 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 />
|
||||
<% end -%>
|
||||
|
||||
<%- 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 />
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
@@ -0,0 +1,12 @@
|
||||
<h2>Resend confirmation instructions</h2>
|
||||
|
||||
<%= 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 %></div>
|
||||
|
||||
<div><%= f.submit "Resend confirmation instructions" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "links" %>
|
||||
@@ -0,0 +1,5 @@
|
||||
<p>Welcome <%= @resource.email %>!</p>
|
||||
|
||||
<p>You can confirm your account email through the link below:</p>
|
||||
|
||||
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
|
||||
@@ -0,0 +1,8 @@
|
||||
<p>Hello <%= @resource.email %>!</p>
|
||||
|
||||
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
|
||||
|
||||
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
|
||||
|
||||
<p>If you didn't request this, please ignore this email.</p>
|
||||
<p>Your password won't change until you access the link above and create a new one.</p>
|
||||
@@ -0,0 +1,7 @@
|
||||
<p>Hello <%= @resource.email %>!</p>
|
||||
|
||||
<p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
|
||||
|
||||
<p>Click the link below to unlock your account:</p>
|
||||
|
||||
<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
|
||||
@@ -0,0 +1,16 @@
|
||||
<h2>Change your password</h2>
|
||||
|
||||
<%= 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 %></div>
|
||||
|
||||
<div><%= f.label :password_confirmation, "Confirm new password" %><br />
|
||||
<%= f.password_field :password_confirmation %></div>
|
||||
|
||||
<div><%= f.submit "Change my password" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "links" %>
|
||||
@@ -0,0 +1,12 @@
|
||||
<h2>Forgot your password?</h2>
|
||||
|
||||
<%= 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 %></div>
|
||||
|
||||
<div><%= f.submit "Send me reset password instructions" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "links" %>
|
||||
@@ -0,0 +1,25 @@
|
||||
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
||||
|
||||
<%= 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 %></div>
|
||||
|
||||
<div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
|
||||
<%= f.password_field :password, :autocomplete => "off" %></div>
|
||||
|
||||
<div><%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation %></div>
|
||||
|
||||
<div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
|
||||
<%= f.password_field :current_password %></div>
|
||||
|
||||
<div><%= f.submit "Update" %></div>
|
||||
<% end %>
|
||||
|
||||
<h3>Cancel my account</h3>
|
||||
|
||||
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
|
||||
|
||||
<%= link_to "Back", :back %>
|
||||
@@ -0,0 +1,29 @@
|
||||
%h2 Sign up
|
||||
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
|
||||
= devise_error_messages!
|
||||
%div
|
||||
= f.label :first_name
|
||||
%br/
|
||||
= f.text_field :first_name
|
||||
%div
|
||||
= f.label :last_name
|
||||
%br/
|
||||
= f.text_field :last_name
|
||||
%div
|
||||
= f.label :nickname
|
||||
%br/
|
||||
= f.text_field :nickname
|
||||
%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 "links"
|
||||
@@ -0,0 +1,28 @@
|
||||
<h2>Sign in</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></div>
|
||||
|
||||
<div><%= f.label :password %><br />
|
||||
<%= f.password_field :password %></div>
|
||||
|
||||
<% if devise_mapping.rememberable? -%>
|
||||
<div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
|
||||
<% end -%>
|
||||
|
||||
<div><%= f.submit "Sign in" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "links" %>
|
||||
|
||||
<% if Rails.env.development? %>
|
||||
<% User.all.each do |user| %>
|
||||
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
||||
<%= f.hidden_field :email, :value => user.email %></div>
|
||||
<%= f.hidden_field :password, :value => 'password' %></div>
|
||||
<div><%= f.submit "Sign in as #{user.email}" %></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<h2>Resend unlock instructions</h2>
|
||||
|
||||
<%= 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 %></div>
|
||||
|
||||
<div><%= f.submit "Resend unlock instructions" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "links" %>
|
||||
@@ -0,0 +1,49 @@
|
||||
!!! 5
|
||||
%html{:lang => "en"}
|
||||
%head
|
||||
%meta{:charset => "utf-8"}/
|
||||
%title= content_for?(:title) ? yield(:title) : "Mash"
|
||||
= csrf_meta_tags
|
||||
/[if lt IE 9]
|
||||
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
||||
:css
|
||||
body {
|
||||
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
|
||||
}
|
||||
= stylesheet_link_tag "application", :media => "all"
|
||||
|
||||
%body
|
||||
.navbar.navbar-fixed-top
|
||||
.navbar-inner
|
||||
.container
|
||||
= link_to 'Mash', root_path, :class => 'brand'
|
||||
.container.nav-collapse
|
||||
%ul.nav
|
||||
%li= link_to "Home", root_path
|
||||
%ul.nav.pull-right
|
||||
- if user_signed_in?
|
||||
%li#logged_in_as
|
||||
= link_to "Hello #{current_user.first_name} #{current_user.last_name}", edit_user_registration_path
|
||||
%li#logout
|
||||
= link_to 'Logout', destroy_user_session_path, :method => :delete
|
||||
- else
|
||||
%li#login
|
||||
= link_to 'Login', new_user_session_path
|
||||
%li#register
|
||||
= link_to 'Register', new_user_registration_path
|
||||
|
||||
.container
|
||||
|
||||
.content
|
||||
- if flash[:notice]
|
||||
%p{:class => 'notice'}= flash[:notice]
|
||||
- if flash[:alert]
|
||||
%p{:class => 'alert'}= flash[:alert]
|
||||
.row
|
||||
.span13
|
||||
= yield
|
||||
|
||||
%footer
|
||||
%p © Rails App Template 2012
|
||||
|
||||
= javascript_include_tag "application"
|
||||
@@ -0,0 +1 @@
|
||||
Do the monster mash!
|
||||
@@ -0,0 +1,9 @@
|
||||
%p
|
||||
= link_to 'Create a Team', new_team_path, :class => 'btn btn-large btn-primary'
|
||||
|
||||
.teams
|
||||
- teams.each do |team|
|
||||
%h3.team= link_to team, team
|
||||
|
||||
= will_paginate teams
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
= form_for team, :html => { :class => 'form-horizontal' } do |f|
|
||||
.control-group{:class => team.errors[:name].present? ? 'error' : ''}
|
||||
= f.label :name, 'Name', :class => 'control-label'
|
||||
.controls
|
||||
= f.text_field :name
|
||||
- if team.errors[:name].present?
|
||||
.help-inline= team.errors[:name].join(', ')
|
||||
.control-group{:class => team.errors[:max_members].present? ? 'error' : ''}
|
||||
= f.label :max_members, 'Max members', :class => 'control-label'
|
||||
.controls
|
||||
= f.text_field :max_members
|
||||
- if team.errors[:max_members].present?
|
||||
.help-inline= team.errors[:max_members].join(', ')
|
||||
.control-group{:class => team.errors[:private_team].present? ? 'error' : ''}
|
||||
= f.label :private_team, 'Private team?', :class => 'control-label'
|
||||
.controls
|
||||
= f.check_box :private_team
|
||||
- if team.errors[:private_team].present?
|
||||
.help-inline= team.errors[:private_team].join(', ')
|
||||
.form-actions
|
||||
= f.submit 'Create Team', :class => 'btn btn-primary'
|
||||
@@ -0,0 +1,11 @@
|
||||
%h3= team
|
||||
|
||||
%ul.members
|
||||
%li= team.captain
|
||||
- team.members.each do |member|
|
||||
%li= member
|
||||
|
||||
- unless current_user.is_a_member_of?(team)
|
||||
= form_tag join_team_path(team) do
|
||||
= submit_tag 'Join team', :class => 'btn'
|
||||
|
||||
Reference in New Issue
Block a user