Skip to content
Snippets Groups Projects
Commit c37ee1d0 authored by Tyler Lemburg's avatar Tyler Lemburg
Browse files

CSS and guardfile

parent 9118bd79
No related branches found
No related tags found
No related merge requests found
Showing
with 433 additions and 0 deletions
# NOTE: the subpath hack using a regexp group no longer works
# - instead, use the patterns option, e.g. change:
#
# guard :less do
# watch /^foo\/(.+)\.less/
# end
#
# into:
#
# patterns = [/^foo\/(.+)\.less/]
# guard :less, patterns: patterns do
# patterns.each { |pattern| watch(pattern) }
# end
less_options = {
all_on_start: true,
all_after_change: true,
patterns: ['Guardfile', 'src/less/resource_scheduler.less'],
output: 'public/css',
compress: true
}
guard :less, less_options do
less_options[:patterns].each { |pattern| watch(pattern) }
end
require 'pony'
class Emailer
def self.mail(to, subject, body, bcc = "", attachments = nil)
Pony.mail({
:to => to,
:bcc => bcc,
:subject => subject,
:html_body => body,
:from => 'resource_scheduler@unl.edu',
:via => self.method,
:via_options => self.method_options,
:attachments => attachments
})
end
private
def self.method
if ENV['RACK_ENV'] == 'development'
:smtp
else
:sendmail
end
end
def self.method_options
if ENV['RACK_ENV'] == 'development'
{
:address => '127.0.0.1',
:port => '1025'
}
else
{}
end
end
end
\ No newline at end of file
require 'active_record'
class AddServiceSpaceUrlName < ActiveRecord::Migration
def change
add_column :service_spaces, :url_name, :string
end
end
\ No newline at end of file
require 'active_record'
class Event < ActiveRecord::Base
has_many :event_signups, :dependent => :destroy
has_one :reservation, :dependent => :destroy
belongs_to :location
belongs_to :event_type
alias_method :type, :event_type
alias_method :signups, :event_signups
scope :in_day, ->(time) {
today = time.in_time_zone.midnight
tomorrow = (time.in_time_zone.midnight + 1.day + 1.hour).in_time_zone.midnight
where('(start_time >= ? AND start_time < ?) OR (end_time >= ? AND end_time < ?)', today.getutc, tomorrow.getutc, today.getutc, tomorrow.getutc)
}
scope :in_week, ->(time) {
last_sunday = time.in_time_zone.week_start
next_sunday = (time.in_time_zone.week_start + 1.week + 1.hour).in_time_zone.week_start
where('(start_time >= ? AND start_time < ?) OR (end_time >= ? AND end_time < ?)', last_sunday.getutc, next_sunday.getutc, last_sunday.getutc, next_sunday.getutc)
}
# returns length in minutes. If start or end is nil, returns 0
def length
if end_time.nil? || start_time.nil?
return 0
end
((end_time - start_time) / 60).to_i
end
def info_link
case type.description
when 'New Member Orientation'
"/new_members/sign_up/#{id}/"
else
"/events/#{id}/"
end
end
def edit_link
"/admin/events/#{id}/edit/"
end
def has_reservation
!self.reservation.nil?
end
def image_src
"/images/#{id}/"
end
def set_data(params)
self.title = params[:title]
self.description = params[:description]
self.start_time = calculate_time(params[:start_date], params[:start_time_hour], params[:start_time_minute], params[:start_time_am_pm])
self.end_time = calculate_time(params[:end_date], params[:end_time_hour], params[:end_time_minute], params[:end_time_am_pm])
self.event_type_id = params[:type]
self.location_id = params[:location]
self.max_signups = params[:limit_signups] == 'on' ? params[:max_signups].to_i : nil
self.service_space_id = 1
self.save
end
def set_image_data(params)
if params[:imagedata]
self.imagemime = params[:imagedata][:type]
self.imagedata = params[:imagedata][:tempfile].read if params[:imagedata][:tempfile].is_a?(Tempfile)
end
self.save
end
def remove_image_data
self.imagemime = nil
self.imagedata = nil
self.save
end
end
\ No newline at end of file
require 'active_record'
class EventSignup < ActiveRecord::Base
belongs_to :event
end
\ No newline at end of file
require 'active_record'
class EventType < ActiveRecord::Base
def name
description
end
end
\ No newline at end of file
require 'active_record'
class Location < ActiveRecord::Base
end
\ No newline at end of file
require 'active_record'
class Permission < ActiveRecord::Base
SUPER_USER = 1
MANAGE_USERS = 2
MANAGE_RESOURCES = 3
MANAGE_EMAILS = 4
MANAGE_SPACE_HOURS = 5
MANAGE_EVENTS = 6
SEE_AGENDA = 7
end
\ No newline at end of file
require 'active_record'
class Reservation < ActiveRecord::Base
belongs_to :resource
belongs_to :event
belongs_to :user
scope :in_day, ->(time) {
today = time.in_time_zone.midnight
tomorrow = (time.in_time_zone.midnight + 1.day + 1.hour).in_time_zone.midnight
where('(start_time >= ? AND start_time < ?) OR (end_time >= ? AND end_time < ?)', today.getutc, tomorrow.getutc, today.getutc, tomorrow.getutc)
}
# returns length in minutes. If start or end is nil, returns 0
def length
if end_time.nil? || start_time.nil?
return 0
end
((end_time - start_time) / 60).to_i
end
end
\ No newline at end of file
require 'active_record'
require 'models/resource_approver'
require 'models/resource_authorization'
class Resource < ActiveRecord::Base
has_many :reservations, dependent: :destroy
has_many :resource_approvers, dependent: :destroy
has_many :resource_authorizations, dependent: :destroy
alias_method :approvers, :resource_approvers
end
\ No newline at end of file
require 'active_record'
class ResourceApprover < ActiveRecord::Base
belongs_to :resource
belongs_to :user
end
\ No newline at end of file
require 'active_record'
class ResourceAuthorization < ActiveRecord::Base
belongs_to :resource
end
\ No newline at end of file
require 'active_record'
class ServiceSpace < ActiveRecord::Base
end
\ No newline at end of file
require 'active_record'
class SpaceHour < ActiveRecord::Base
serialize :hours, Array
end
\ No newline at end of file
require 'active_record'
require 'bcrypt'
require 'models/resource_authorization'
require 'models/event_signup'
require 'models/permission'
require 'models/user_has_permission'
require 'classes/emailer'
class User < ActiveRecord::Base
has_many :resource_authorizations
has_many :event_signups
has_many :user_has_permissions
has_many :permissions, through: :user_has_permissions
def authorized_resource_ids
self.resource_authorizations.map {|res_auth| res_auth.resource_id}
end
def get_authorization(resource_id)
self.resource_authorizations.where(:resource_id => resource_id).first
end
def signed_up_event_ids
self.event_signups.map {|event_signup| event_signup.event_id}
end
include BCrypt
# now decides based on whether they have any admin permissions
def is_admin?
!self.permissions.empty?
end
alias_method :admin?, :is_admin?
def is_super_user?
self.permissions.include?(Permission.find(Permission::SUPER_USER))
end
alias_method :super_user?, :is_super_user?
def has_permission?(id)
self.permissions.include?(Permission.find(id))
end
def password
@password ||= Password.new(password_hash)
end
def password=(new_password)
@password = Password.create(new_password)
self.password_hash = @password
end
def full_name
"#{first_name} #{last_name}"
end
def sortable_name
"#{last_name}, #{first_name}"
end
def send_reset_password_email
token = ''
begin
token = String.token
end while User.find_by(:reset_password_token => token) != nil
self.reset_password_token = token
self.reset_password_expiry = Time.now + 1.day
self.save
body = <<EMAIL
<p>We received a request to reset your Innovation Studio Manager password. Please click the link below to reset your password.</p>
<p><a href="http://#{ENV['RACK_ENV'] == 'development' ? 'localhost:9393' : 'innovationstudio-manager.unl.edu'}/reset_password/#{token}/">http://#{ENV['RACK_ENV'] == 'development' ? 'localhost:9393' : 'innovationstudio-manager.unl.edu'}/reset_password/#{token}/</a></p>
<p>This link will only be active for 24 hours. If you did not request to reset your password, you may safely disregard this email.</p>
<p>Nebraska Innovation Studio</p>
EMAIL
Emailer.mail(self.email, 'Nebraska Innovation Studio password reset', body)
end
end
\ No newline at end of file
require 'active_record'
class UserHasPermission < ActiveRecord::Base
belongs_to :user
belongs_to :permission
end
\ No newline at end of file
This diff is collapsed.
require 'models/event'
require 'models/space_hour'
get '/:service_space_url_name/calendar/?' do
load_service_space
@breadcrumbs << {:text => "#{@space.name} Calendar"}
# get all events for this week
date = params[:date].nil? ? Time.now : Time.parse(params[:date])
events = Event.includes(:event_type).where(:service_space_id => @space.id).in_week(date).all
sunday = date.in_time_zone.week_start
hours = SpaceHour.where(:service_space_id => @space.id)
.where('effective_date < ?', (sunday+1.week+1.hour).midnight.utc.strftime('%Y-%m-%d %H:%M:%S'))
.order(:day_of_week, :effective_date => :desc, :id => :desc).all.to_a
hours_days = hours.group_by do |space_hour|
space_hour.day_of_week
end
week_hours = {}
hours_days.each do |number_of_days, array|
this_day = (sunday + number_of_days.days + 1.hour).midnight
# find the correct hour record to use for this day
array.each do |space_hour|
if space_hour.effective_date.in_time_zone.midnight == this_day.in_time_zone.midnight || (!space_hour.one_off && space_hour.effective_date.in_time_zone.midnight <= this_day.in_time_zone.midnight)
week_hours[number_of_days] = space_hour
break
end
end
end
erb :calendar, :layout => :fixed, :locals => {
:date => date,
:sunday => sunday,
:events => events,
:week_hours => week_hours
}
end
@bp1: ~" (min-width: 480px)";
@bp2: ~" (min-width: 768px)";
@bp3: ~" (min-width: 960px)";
@bp4: ~" (min-width: 1044px)";
// For styles which shouldn't cascade to other breakpoints
@only-bp1: ~" (min-width: 480px) and (max-width: 767px) ";
@only-bp2: ~" (min-width: 768px) and (max-width: 959px)";
@only-bp3: ~" (min-width: 960px) and (max-width: 1043px)";
@under-bp2: ~" (max-width: 767px) ";
// The navigation breaks from the traditional media queries
@bp-nav-hidden: ~" (max-width: 699px)";
@bp-nav-full: ~" (min-width: 700px)";
@bp-nav-max: ~" (min-width: 1016px)"; // nav toggle width + bp3
// GO B1G RED
// Scarlet
@scarlet: #d00000;
@brand: @scarlet;
// Cream
@cream: #fefdfa;
@page-background: @cream; // A color to represent the page background, used for WDN colors
// UI
// Light (<50%)
@ui01: mix(#000, @cream, 2%); // #f9f8f5
@ui02: mix(#000, @cream, 4%); // #f4f3f0
@ui03: mix(#000, @cream, 8%); // #eae9e6
@ui04: mix(#000, @cream, 16%); // #d5d5d2
@ui05: mix(#000, @cream, 24%); // #c1c0be
@ui06: mix(#000, @cream, 32%); // #adacaa
@ui07: mix(#000, @cream, 48%); // #848482
// Dark (>50%)
@ui08: mix(#000, @cream, 64%); // #5b5b5a
@ui09: mix(#000, @cream, 72%); // #474746
@ui10: mix(#000, @cream, 80%); // #333332
@ui11: mix(#000, @cream, 82%); // #2e2e2d
@ui12: mix(#000, @cream, 84%); // #292828
@ui13: mix(#000, @cream, 88%); // #1e1e1e
@ui14: mix(#000, @cream, 92%); // #141414
// A few neutral shades, light tan and dark brown
@neutral: #4a3b13;
@light-neutral: lighten(desaturate(@neutral, 15%), 5%);
@dark-neutral: darken(mix(@neutral, #666, 60%), 5%);
@faded-neutral: mix(#3b3816, @page-background, 5%); // To be used for subtle color variations. Works OK on most banded colors
// Base spinner
@base-spinner: #137cbd;
// Color triads, in the blue family
@triad: @base-spinner;
@light-triad: lighten(@triad, 10%);
@dark-triad: mix(@triad, #666, 45%);
// Color complementary, in the green family
@complement: #00892c;
@light-complement: lighten(@complement, 10%);
@dark-complement: mix(@complement, #666, 45%);
// Color complementary, in the orange family
@energetic: #d4440b;
@light-energetic: lighten(@energetic, 10%);
@dark-energetic: mix(@energetic, #666, 70%);
// Assign base colors
// Base text and heading text colors
@heading-text: @ui09;
@base-text: @ui08;
// Warnings. Since red is our brand color, we're using a brighter orange
@warning: #ffa500;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment