Lot of styles, and some other stuff

This commit is contained in:
benji 2015-03-19 14:59:37 +01:00
parent 0c06c4bedb
commit 191517bda7
16 changed files with 117 additions and 91 deletions

View file

@ -44,6 +44,8 @@ end
group :test do
gem 'capybara'
gem 'launchy'
gem "codeclimate-test-reporter", require: nil
gem 'faker', '1.4.2'
end
#bootstrap
@ -65,9 +67,6 @@ gem 'devise'
# Use cancancan for authorization
gem 'cancancan'
#ik wil test data maken dus dit
gem 'faker', '1.4.2'
# Safety first
gem 'paper_trail', '~> 4.0.0.beta'
@ -76,4 +75,4 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
gem 'coveralls', require: false
gem "codeclimate-test-reporter", group: :test, require: nil
gem 'omniauth'

View file

@ -111,6 +111,7 @@ GEM
ffi (1.9.6-x64-mingw32)
globalid (0.3.2)
activesupport (>= 4.1.0)
hashie (3.4.0)
hike (1.2.3)
i18n (0.7.0)
jbuilder (2.2.6)
@ -140,6 +141,9 @@ GEM
mini_portile (~> 0.6.0)
nokogiri (1.6.6.2-x64-mingw32)
mini_portile (~> 0.6.0)
omniauth (1.2.2)
hashie (>= 1.2, < 4)
rack (~> 1.0)
orm_adapter (0.5.0)
paper_trail (4.0.0.beta2)
activerecord (>= 3.0, < 6.0)
@ -263,6 +267,7 @@ DEPENDENCIES
jquery-rails
launchy
mysql2
omniauth
paper_trail (~> 4.0.0.beta)
paperclip
rails (= 4.2)

View file

@ -29,83 +29,57 @@ $gray-medium-light: #eaeaea;
}
/* miscellaneous */
.nowrap {
white-space: nowrap;
}
.center{
text-align: center;
}
.form-field{
margin-bottom: 15px;
text-align: bottom;
}
/* bootstrap */
/* boostrap */
body {
padding-top: 80px;
}
/* footer */
footer {
margin-top: 45px;
padding-top: 5px;
border-top: 1px solid #eaeaea;
border-top: 1px solid $gray-medium-light;
color: #777;
}
footer a {
color: #555;
}
footer a:hover {
color: #222;
}
footer small {
float: left;
}
footer ul {
float: right;
list-style: none;
}
footer ul li {
float: left;
margin-left: 15px;
}
.overview{
margin-bottom: 0px;
border: 0px;
.btn{
margin-top: -55px;
width: 80%;
margin-left:10%;
border: 0px;
a {
color: #555;
&:hover {
color: #222;
}
}
.dagschotel{
float:left;
position: absolute;
small {
float: left;
}
.avatar{
height: 150px;
width: 150px;
ul {
float: right;
list-style: none;
li {
float: left;
margin-left: 15px;
}
}
}
.center{
text-align: center;
}
.debug_dump{
width: 100%;
margin-top: 30px;
}
.form-field{
margin-bottom: 15px;
text-align: bottom;
}
.nav-logo{
margin:10px;
font-size:30px;

View file

@ -18,13 +18,13 @@
margin-left: auto;
margin-right: auto;
position: relative;
img {
position: absolute;
top: 0;
bottom: 0;
left: 0;
top: 0;
margin: auto;
}
}
.form_row_image img {
position: absolute;
top: 0;
bottom: 0;
left: 0;
top: 0;
margin: auto;
}

View file

@ -0,0 +1,21 @@
.overviewthumbnail {
margin-bottom: 0px;
border: 0px;
.btn{
margin-top: -55px;
width: 80%;
margin-left:10%;
border: 0px;
}
.dagschotel{
float:left;
position: absolute;
}
.avatar{
height: 150px;
width: 150px;
}
}

View file

@ -62,7 +62,7 @@ class OrdersController < ApplicationController
redirect_to root_path
end
unless current_user.koelkast? || current_user == @user
unless current_user.koelkast? || current_user.admin? || current_user == @user
flash[:error] = "Please don't order stuff for other people"
redirect_to root_path
end

View file

@ -31,15 +31,30 @@ class UsersController < ApplicationController
redirect_to users_path
end
def dagschotel
user = User.find(params[:user_id])
def edit_dagschotel
@user = User.find(params[:user_id])
@dagschotel = @user.dagschotel
end
if user.update_attributes(dagschotel: Product.find(params[:product_id]))
def update_dagschotel
@user = User.find(params[:user_id])
@user.dagschotel = Product.find(params[:product_id])
if @user.save
flash[:success] = "Succesfully updated dagschotel"
redirect_to @user
else
flash[:error] = "Error updating dagschotel"
@dagschotel = @user.reload.dagschotel
render 'edit_dagschotel'
end
redirect_to edit_user_registration_path(user)
end
private
def init
@user = User.find(params[:user_id])
redirect_to root_path, error: "You are not authorized to access this page." unless @user == current_user || current_user.admin?
end
end

View file

@ -11,7 +11,8 @@ class Ability
elsif user[:id]
can :read, :all
can :update, User
can :dagschotel, User
can :edit_dagschotel, User
can :update_dagschotel, User
can :create, Order
end
end

View file

@ -13,15 +13,3 @@
<%= f.submit "Update" %>
<% end %>
<% if current_user.dagschotel.present? %>
<h3>Current Dagschotel:</h3>
<div>
<%= image_tag current_user.dagschotel.avatar %>
</div>
<% end %>
<h4>Choose new Dagschotel:</h4>
<% Product.all.each do |p| %>
<%= link_to image_tag(p.avatar), user_dagschotel_path(current_user, p) %>
<% end %>

View file

@ -12,12 +12,12 @@
<% else %>
<body>
<% end %>
<%= render "layouts/header" %>
<%= render 'layouts/header' %>
<div class="container">
<div class="container" >
<div class="container">
<%= yield %>
</div>
<%= render "layouts/footer" %>
<%= render 'layouts/footer' %>
<%= debug(params) if Rails.env.development? %>
</div>
</body>

View file

@ -1,4 +1,4 @@
<div class="col-md-2 thumbnail overview">
<div class="col-md-2 overviewthumbnail">
<% unless user.dagschotel.nil? %>
<%= link_to user_quickpay_path(user) do %>
<%= image_tag user.dagschotel.avatar(:dagschotel), class: "img-circle dagschotel" %>

View file

@ -0,0 +1,11 @@
<% if current_user.dagschotel.present? %>
<h3>Current Dagschotel:</h3>
<div>
<%= render current_user.dagschotel %>
</div>
<% end %>
<h4>Choose new Dagschotel:</h4>
<% Product.all.each do |p| %>
<%= link_to image_tag(p.avatar), user_dagschotel_path(current_user, p) %>
<% end %>

View file

@ -1,7 +1,10 @@
<%= render partial: 'flash' %>
<div class="row">
<div class="user_info">
<h5><%= link_to "[Edit profile]" , edit_user_registration_path if current_user == @user%></h5>
<h5>
<%= link_to "[Edit dagschotel]" , user_edit_dagschotel_path(@user) if current_user == @user %>
<%= link_to "[Edit profile]" , edit_user_registration_path if current_user == @user %>
</h5>
<h2><%= @user.nickname %> (<%= @user.full_name %>)</h2>
<%= button_to "PLACE ORDER!", new_user_order_path(@user), method: :get if current_user == @user %>
<div class="balance">BALANCE: <%= euro(@user.balance) %></div>

View file

@ -17,8 +17,9 @@ Rails.application.routes.draw do
resources :users do
resources :orders
get 'quickpay' => 'orders#quickpay'
get 'dagschotel/:product_id' => 'users#dagschotel', as: "dagschotel"
get 'quickpay' => 'orders#quickpay'
get 'dagschotel/edit' => 'users#edit_dagschotel', as: 'edit_dagschotel'
get 'dagschotel/:product_id' => 'users#update_dagschotel', as: 'dagschotel'
end
resources :products do

View file

@ -0,0 +1,6 @@
class AddColumnsToUsers < ActiveRecord::Migration
def change
add_column :users, :provider, :string
add_column :users, :uid, :string
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150310150231) do
ActiveRecord::Schema.define(version: 20150319134138) do
create_table "order_items", force: :cascade do |t|
t.integer "order_id"
@ -65,6 +65,8 @@ ActiveRecord::Schema.define(version: 20150310150231) do
t.datetime "avatar_updated_at"
t.integer "orders_count", default: 0
t.boolean "koelkast", default: false
t.string "provider"
t.string "uid"
end
add_index "users", ["koelkast"], name: "index_users_on_koelkast"