Prepare some things for production phase

This commit is contained in:
benji 2015-12-31 17:30:57 +01:00
parent 0a1747246e
commit e91e3213d7
7 changed files with 23 additions and 16 deletions

View file

@ -20,7 +20,6 @@
}
}
.warning {
border: 2px solid;
.guest {
margin-bottom: 20px;
}

View file

@ -8,9 +8,9 @@ class WelcomeController < ApplicationController
if user_signed_in? || params[:token] != Rails.application.secrets.koelkast_token
redirect_to root_path
return
else
koelkast = User.find_by(name: "koelkast")
sign_in_and_redirect koelkast
end
koelkast = User.koelkast
sign_in_and_redirect koelkast
end
end

View file

@ -4,7 +4,7 @@ class Ability
def initialize(user)
return unless user
initialize_admin if user.admin?
initialize_admin if user.admin?
initialize_koelkast if user.koelkast?
initialize_user(user)

View file

@ -16,5 +16,5 @@ class Barcode < ActiveRecord::Base
belongs_to :product
validates :product, presence: true
validates :code, presence: true, uniqueness: true
validates :code, presence: true, uniqueness: true
end

View file

@ -21,7 +21,7 @@ class Product < ActiveRecord::Base
include Avatarable
has_many :order_items
has_many :barcodes
has_many :barcodes, dependent: :destroy
accepts_nested_attributes_for :barcodes
enum category: %w(food beverages other)

View file

@ -56,6 +56,8 @@ class User < ActiveRecord::Base
end
end
# Static Users
def self.guest
@guest || find_or_create_by(name: "Guest") do |user|
user.avatar = File.new(File.join("app", "assets", "images", "guest.png"))
@ -65,4 +67,11 @@ class User < ActiveRecord::Base
def guest?
self == User.guest
end
def self.koelkast
@koelkast || find_or_create_by(name: "Koelkast") do |user|
user.avatar = File.new(File.join("app", "assets", "images", "logo.png"))
user.koelkast = true
end
end
end

View file

@ -1,13 +1,12 @@
.warning.center
%h1 TESTFASE | GELIEVE STREEPJES TE BLIJVEN ZETTEN | TESTFASE
.row
.col-md-1
%h5 Recent
#last
- @last.each do |user|
= image_tag user.avatar(:small), class: "img-responsive img-circle img-thumbnail"
- unless @last.empty?
%h5 Recent
#last
- @last.each do |user|
= image_tag user.avatar(:small), class: "img-responsive img-circle img-thumbnail"
.col-md-11
.row.text-center
=link_to "Not a Zeus Account? Order as a guest.", new_guest_order_path, class: "btn btn-primary btn-lg"
.row.text-center.guest
=link_to "Not a Zeus Account? Order as a guest.", new_guest_order_path, class: "btn btn-default btn-lg"
.row
= render @users