The <input> types
element is a
container for different types of input
elements, such as:
text fields, checkboxes, radio buttons, submit buttons, etc. It represents a document section
containing interactive controls for submitting information.
All the different form elements are covered in
the list below:


1.What is the short form of HTML?
HTML
HMLT
MHLT
2.What is the other name for java script?
ECMAscript.
js
I don't know.
3.Is C++ a low level language?
no
yes


Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively.
I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively.
I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively.
Here is some more information about this product that is only revealed once clicked on.
Here is some more information about this product that is only revealed once clicked on.


--- layout: default title: About description: about: active ---
Graduated from the University of Puerto Rico, having completed a computer Science bachelor. Other accademic interests included physics, businness management, and photogrphy.
I am also a Red Cross certified lifeguard. This was initially part of a college course, it became an opportunity after working as a lifeguard on private events.


Contains published data sets for global benthic d18O data for 0-5.3 Myr <doi:10.1029/2004PA001071> and global sea levels based on marine sediment core data for 0-800 ka <doi:10.5194/cp-12-1-2016>.
| Version: | 0.1.0 |
| Depends: | R (≥ 3.3.0) |
| Suggests: | knitr, rmarkdown, ggplot2 |
| Published: | 2017-06-29 |
| Author: | Ben Marwick [aut, cre], Lorraine Lisiecki [aut], Rachel Spratt [aut], Maureen Raymo [aut] |
| Maintainer: | Ben Marwick <benmarwick at gmail.com> |
| License: | MIT + file LICENSE |
| NeedsCompilation: | no |
| Materials: | README NEWS |
| CRAN checks: | gsloid results |
| Reference manual: | gsloid.pdf |
| Vignettes: |
Vignette Title |
| Package source: | gsloid_0.1.0.tar.gz |
| Windows binaries: | r-devel: gsloid_0.1.0.zip, r-release: gsloid_0.1.0.zip, r-oldrel: gsloid_0.1.0.zip |
| OS X binaries: | r-release: gsloid_0.1.0.tgz, r-oldrel: gsloid_0.1.0.tgz |
Please use the canonical form https://CRAN.R-project.org/package=gsloid to link to this page.


All Files (98.06% covered at 6.95 hits/line)
59 files in total.
979 relevant lines.
960 lines covered and
19 lines missed
- 1
class Admin::UsersController < ApplicationController
- 1
load_and_authorize_resource
- 1
def index
- 3
@users = @users.paginate :page => params[:page], :per_page => 25
- 3
index_respond @users, :users
end
- 1
def create
@user = User.new(user_params)
if @user.save
flash[:notice] = (t 'admins.create_user_success')
redirect_to admin_users_path
else
flash[:error] = (t 'admins.create_user_fail')
render 'new'
end
end
- 1
def new
end
- 1
def edit
end
- 1
def show
end
- 1
def update
# very difficult to do normal update due to "Blank password" issue
# instead we validate and update the parameters individually
- 2
success = @user.update_attributes_manual user_params
- 2
if success
- 1
flash[:notice] = (t 'admins.update_user_success')
- 1
redirect_to admin_users_path
else
- 1
flash[:error] = (t 'admins.update_user_fail')
- 1
render 'edit'
end
end
- 1
def destroy
- 1
if @user.destroy
- 1
flash[:notice] = (t 'admins.remove_user_success')
else
flash[:error] = (t 'admins.remove_user_fail')
end
- 1
redirect_to admin_users_path
end
- 1
private
- 1
def user_params
- 4
up = params.require(:user).permit(
:avatar,
:first_name,
:last_name,
:email,
:password,
:password_confirmation,
:phone,
:role
)
# advice from http://stackoverflow.com/a/27993366
- 4
if !up[:password].present? and !up[:password_confirmation].present?
- 4
up.delete(:password)
- 4
up.delete(:password_confirmation)
end
- 4
return up
end
end
- 1
class AdminController < ApplicationController
- 1
load_and_authorize_resource :class => "Iteration"
- 1
def index
end
- 1
def change_phase
- 4
new_phase = params[:phase]
- 4
@current = Iteration.get_current
#TODO: prevent invalid values from updating status
- 4
@current.status = new_phase.to_i
- 4
authorize! :update, @current
- 4
@current.save
- 4
if @current.status == "voting"
# Send an email notice to everyone who has used the system
- 1
@to = get_addresses User.roles.keys
- 1
@subj = "PauseLab - Voting Period Now Open"
- 1
@body = "Dear PauseLab users, the voting period for proposal submissions is now open!"
- 1
SlpMailer.email_custom_text_bcc(@to, @subj, @body).deliver
end
- 4
render 'edit_phase'
end
# ran into issues comparing strings to symbols
- 1
def next_phase
- 2
@current = Iteration.get_current
- 2
@current.status = case @current.status
- 1
when "ideas" then "proposals"
- 1
when "proposals" then "voting"
else "voting"
end
- 2
@current.save
- 2
render json: {:status => @current.status}
end
- 1
def end_phase
- 1
prev = Iteration.get_current
- 1
prev.ended = Time.now
- 1
prev.status = "ended"
- 1
prev.save
- 1
@current = Iteration.new
- 1
@current.save
- 1
render 'edit_phase'
end
- 1
def edit_phase
- 1
@current = Iteration.get_current
- 1
authorize! :edit, @current
end
- 1
def export_iterations
- 1
@iterations = Iteration.where :status => "ended"
end
- 1
require 'tempfile'
- 1
require 'zip'
- 1
def export_zip
- 1
@iteration = Iteration.find params[:num]
- 1
ideas_file = Tempfile.new(['ideas', '.txt'])
- 1
proposals_file = Tempfile.new(['proposals', '.txt'])
- 1
blogs_file = Tempfile.new(['blogs', '.txt'])
- 1
zip = Tempfile.new(["export", ".zip"])
- 1
begin
- 1
ideas_file.write (@iteration.ideas.to_csv is_admin: user_has_admin_access?)
- 1
ideas_file.flush
- 1
proposals_file.write (@iteration.proposals.to_csv is_admin: user_has_admin_access?)
- 1
proposals_file.flush
- 1
blogs_file.write (@iteration.blogs.to_csv is_admin: user_has_admin_access?)
- 1
blogs_file.flush
- 1
Zip::OutputStream.open(zip) { |zos| }
- 1
Zip::File.open(zip.path, Zip::File::CREATE) do |zip|
#Put files in here
- 1
zip.add("ideas.csv", ideas_file.path)
- 1
zip.add("proposals.csv", proposals_file.path)
- 1
zip.add("blogs.csv", blogs_file.path)
end
- 1
zip_data = File.read(zip.path)
- 1
send_data(zip_data, :type => 'application/zip', :filename =><EMAIL_ADDRESS>ensure
- 1
ideas_file.close
- 1
ideas_file.unlink
- 1
zip.close
- 1
zip.unlink
end
end
end
- 1
class ApplicationController < ActionController::Base
- 1
protect_from_forgery with: :exception
- 1
enable_authorization unless :devise_controller?
# adding below for mass assignment of user fields
- 1
before_action :configure_permitted_parameters, if: :devise_controller?
# strong params config to work with cancan
- 1
before_action do
- 211
resource = controller_name.singularize.to_sym
- 211
method = "#{resource}_params"
- 211
params[resource] &&= send(method) if respond_to?(method, true)
end
# setting locale during the lifetime of this request
- 1
before_action do
- 211
I18n.locale = params[:locale] || I18n.default_locale
end
# catch unauthorization exception message
- 1
rescue_from CanCan::AccessDenied do |exception|
- 14
respond_to do |format|
- 28
format.html { redirect_to main_app.root_url, notice: exception.message }
- 14
format.json { head :forbidden, content_type: 'text/html' }
- 14
format.csv { head :forbidden, content_type: 'text/html' }
- 14
format.js { head :forbidden, content_type: 'text/html' }
end
end
# apply locale to the url route if it is not the default
- 1
def default_url_options
- 112
{ locale: I18n.locale != I18n.default_locale ? I18n.locale : nil }
end
- 1
def after_sign_in_path_for(resource)
#stored_location_for(resource) ||
- 5
if resource.is_a?(User) && resource.admin?
- 1
admin_users_url
- 4
elsif resource.is_a?(User) && resource.moderator?
- 1
admin_edit_phase_url
- 3
elsif (resource.is_a?(User) && resource.artist?) || (resource.is_a?(User) && resource.super_artist?)
- 1
artist_home_url
- 2
elsif resource.is_a?(User) && resource.steerer?
- 1
steering_home_url
else
- 1
root_url
end
end
- 1
protected
- 1
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :phone])
devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name, :phone, :email, :password, :avatar])
end
- 1
def index_respond scoped_objs, name
- 45
respond_to do |format|
- 45
format.html
- 45
format.json { render json: scoped_objs }
- 51
format.csv { send_data (scoped_objs.to_csv is_admin: user_has_admin_access?), filename: "#{name}-#{DateTime.current}.csv"}
end
end
# given a list of user roles, returns a list of email addresses of users in those roles
- 1
def get_addresses(roles)
- 2
to = []
- 2
roles.each do |role|
- 8
if role.to_s == "resident"
# get emails from Vote and Idea models, which aren't attached to User
- 2
to.concat(Vote.pluck(:email).reject{ |e| e.nil? or e.blank? })
- 3
to.concat(Idea.pluck(:email).reject{ |e| e.nil? or e.blank? })
end
- 8
to.concat(User.where(role: role).pluck(:email))
end
- 2
return to.uniq
end
# returns whether user is an admin or moderator
- 1
def user_has_admin_access?
- 39
return ((not current_user.nil?) and (current_user.admin? or current_user.moderator?))
end
- 1
helper_method :user_has_admin_access?
# returns whether user is admin, moderator, or steering committee
- 1
def user_has_steering_access?
- 24
return ((not current_user.nil?) and (current_user.admin? or current_user.moderator? or current_user.steerer?))
end
- 1
helper_method :user_has_steering_access?
end
- 1
class BlogsController < ApplicationController
- 1
load_and_authorize_resource
- 1
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
- 1
def index
# @blogs = @blogs.where(:iteration_id => Iteration.get_current.id)
# blogs are independet from all iterations so all blogs can be accessed
- 2
@blogs = @blogs.all
.order(created_at: :desc)
.paginate :page => params[:page], :per_page => 10
- 2
index_respond @blogs, :blogs
end
- 1
def admin_console
- 1
@blogs = Blog.all
- 1
authorize! :read, @blogs
end
- 1
def show
end
- 1
def new
end
- 1
def create
- 5
@blog = Blog.new(blog_params)
- 5
@blog.user_id = current_user.id
- 5
@blog.iteration_id = Iteration.get_current.id
- 5
if @blog.save
- 4
flash[:notice] = (t 'blogs.save_success')
- 4
redirect_to blogs_path
else
- 1
flash[:error] = (t 'blogs.save_error')
- 1
render new_blog_path
end
end
- 1
def edit
end
- 1
def destroy
- 3
@blog.destroy
- 3
redirect_to blogs_path
end
- 1
def update
- 4
if @blog.update blog_params
- 3
redirect_to @blog
else
- 1
render "edit"
end
end
- 1
def record_not_found
- 1
flash[:error] = (t 'common.record_not_found')
- 1
redirect_to action: :index
end
- 1
private
- 1
def blog_params
- 26
params.require(:blog).permit(
:title,
:key_img,
:body
)
end
end
- 1
class CategoriesController < ApplicationController
- 1
load_and_authorize_resource
- 1
def index
- 3
@category = Category.new
- 3
index_respond @categories, :categories
end
- 1
def show
end
- 1
def new
end
- 1
def create
- 3
@category = Category.new category_params
- 3
respond_to do |format|
- 3
if @category.save
- 4
format.html { redirect_to categories_path, notice: (t 'categories.save_success') }
- 2
format.json { render json: @resource }
else
- 2
format.html { render new_category_path, error: (t 'categories.save_error') }
- 1
format.json { render json: @resource }
end
end
end
- 1
def edit
end
- 1
def destroy
- 2
@category.destroy
- 2
redirect_to categories_path
end
- 1
def update
- 3
if @category.update category_params
- 2
redirect_to @category
else
- 1
render 'edit'
end
end
- 1
private
- 1
def category_params
- 18
params.require(:category).permit(
:name,
:icon
)
end
end
- 1
class IdeasController < ApplicationController
- 1
load_and_authorize_resource
- 1
def index
- 16
@ideas = filter_idea_columns(@ideas.where(:iteration_id => Iteration.get_current.id))
.paginate :page => params[:page], :per_page => 25
- 16
case params[:sort]
when "category"
- 1
@ideas = @ideas.order :category_id
when "id"
- 1
@ideas = @ideas.order :id
when "date"
- 1
@ideas = @ideas.order created_at: :desc
when "last_name"
- 1
if user_has_admin_access? # prevent non-privileged users from sorting
- 1
@ideas = @ideas.order :last_name
end
when "first_name"
- 1
if user_has_admin_access? # prevent non-privileged users from sorting
- 1
@ideas = @ideas.order :first_name
end
when "likes"
- 1
@ideas = @ideas.order likes: :desc
end
- 16
if params[:status].present?
- 1
@ideas = @ideas.where(status: Idea.statuses[params[:status]])
end
- 16
@likes = Array.new
- 16
if cookies[:likes] != nil
- 2
@likes = JSON.parse(cookies[:likes])
end
- 16
index_respond @ideas, :ideas
end
- 1
alias_method :card_index, :index
- 1
def new
end
- 1
def edit
end
- 1
def create
- 8
@idea = Idea.new(idea_params)
- 8
@to = @idea.email
- 8
@idea.iteration_id = Iteration.get_current.id
- 8
if @idea.save
- 7
flash[:notice] = (t 'ideas.save_success')
- 7
SlpMailer.email_custom_text(@to, (t 'ideas.thanks_subject', :name => @idea.first_name),
- 14
(t 'ideas.thanks_body', :name => @idea.first_name)).deliver
- 7
redirect_to root_path
else
- 1
flash[:error] = (t 'ideas.save_error')
- 1
render 'new'
end
end
- 1
def show
- 1
@idea = filter_idea_columns(Idea.where(:id => params[:id])).first
end
# TODO: make this into an AJAX call
- 1
def like
- 5
@id = @idea.id
- 5
@likes = Array.new
#Check if cookie already exists
- 5
if cookies[:likes] != nil
- 3
@likes = JSON.parse(cookies[:likes])
#Only add new like to cookie if it doesn't already have it
- 3
if @likes.include?(@id)
#Decrease value in database
- 2
@idea = Idea.find(params[:id])
- 2
@idea.decrement!(:likes)
- 2
@idea.save
#Update likes cookie
- 2
@likes.delete(@id)
- 2
@json_likes = JSON.generate(@likes)
- 2
cookies[:likes] = @json_likes
else
#Update database values
- 1
@idea = Idea.find(params[:id])
- 1
@idea.increment!(:likes)
- 1
@idea.save
- 1
@likes.push(@id)
- 1
@json_likes = JSON.generate(@likes)
- 1
cookies[:likes] = @json_likes
end
#Else make a new cookie!
else
#Update database values
- 2
@idea = Idea.find(params[:id])
- 2
@idea.increment!(:likes)
- 2
@idea.save
#Make a new cookie
- 2
@likes.push(@id)
- 2
@json_likes = JSON.generate(@likes)
- 2
cookies[:likes] = { :value => @json_likes, :expires => Time.now + 2628000 }
end
- 5
@div_id =<EMAIL_ADDRESS>- 5
respond_to do |format|
- 5
format.html
- 5
format.js
end
#redirect_to ideas_path
end
- 1
def destroy
- 2
@idea.destroy
- 2
redirect_to ideas_path
end
- 1
def update
- 8
if @idea.update idea_params
- 7
redirect_to @idea
else
- 1
render 'edit'
end
end
- 1
def approve
- 2
@idea = Idea.find(params[:id])
- 2
if @idea.approved?
- 1
@idea.unchecked!
else
- 1
@idea.approved!
end
- 2
@idea.save
- 2
render 'show'
end
- 1
private
- 1
def idea_params
- 40
params.require(:idea).permit(
:first_name,
:last_name,
:category_id,
:email,
:phone,
:description,
:medium,
:address,
:lat,
:lng
)
end
- 1
def filter_idea_columns ideas
- 17
unless user_has_steering_access?
- 3
return ideas.select(:id,:address,:created_at,:likes,:lat,:lng,:category_id,:description)
end
- 14
return ideas
end
end
- 1
class LandingpagesController < ApplicationController
- 1
load_and_authorize_resource
- 1
def index
- 2
index_respond @landingpages, :landing_pages
end
- 1
def new
end
- 1
def create
- 4
@landingpage = Landingpage.new(landingpage_params)
- 4
if @landingpage.save
- 2
flash[:notice] = (t 'landingpages.save_success')
- 2
redirect_to landingpages_path
else
- 2
flash[:error] = (t 'landingpages.save_error')
- 2
render 'new'
end
end
- 1
def edit
end
- 1
def update
- 8
if @landingpage.update landingpage_params
- 7
flash[:notice] = (t 'landingpages.save_success')
- 7
if @landingpage.ideas_home?
- 1
redirect_to ideas_home_path
- 6
elsif @landingpage.artist_home?
- 1
redirect_to artist_home_path
- 5
elsif @landingpage.steering_home?
- 2
redirect_to steering_home_path
- 3
elsif @landingpage.about?
- 3
redirect_to about_path
else
redirect_to root_path
end
else
- 1
flash[:error] = (t 'landingpages.save_error')
- 1
render 'edit'
end
end
- 1
private
- 1
def landingpage_params
- 30
params.require(:landingpage).permit(
:title,
:description
)
end
end
- 1
class MassEmailsController < ApplicationController
- 1
load_and_authorize_resource
# NOTE many methods are handled automatically with load_and_authorize_resource
- 1
def index
- 3
index_respond @mass_emails, :mass_emails
end
- 1
def new
end
- 1
def show
end
- 1
def create
# Get list of user roles selected for this mass email
- 21
roles = User.roles.keys.select { |role| mass_email_params[:to].include? role.to_s }
- 3
@mass_email.to = roles.to_s
# Reject is role list is empty
- 3
if !roles.empty? && @mass_email.save
- 1
flash[:notice] = (t 'mass_emails.save_success')
# Get list of addresses corresponding to those roles
- 1
@to = get_addresses roles
#Send e-mail
- 1
@subj = @mass_email.subject
- 1
@body = @mass_email.body
- 1
SlpMailer.email_custom_text_bcc(@to, @subj, @body).deliver
#After email is sent redirect to the mass email console
- 1
redirect_to mass_emails_path
else
- 2
flash[:error] = (t 'mass_emails.save_error')
- 2
render new_mass_email_path
end
end
- 1
def destroy
- 1
@mass_email.destroy
- 1
redirect_to mass_emails_path
end
- 1
private
- 1
def mass_email_params
- 24
params.require(:mass_email).permit(
:subject,
:body,
:to => []
)
end
end
- 1
class PagesController < ApplicationController
- 1
def go_home
- 4
case Iteration.get_current.status
when 'ideas'
- 2
redirect_to :action => :ideas
when 'proposals'
- 1
redirect_to :action => :card_index, :controller => :ideas
when 'voting'
- 1
redirect_to :action => :new, :controller => :votes
# when 'progress'
# redirect_to :action => :index, :controller => :blogs
#else
# render :text => 'not in ideas'
end
end
- 1
def get_ideas
# map will show ideas that current user is authorized to see
- 1
redirect_to ideas_path(:format => :json)
end
- 1
def get_categories
- 1
authorize! :read, Category
- 1
ret_cat = {}
- 1
categories = Category.all.each do |cat|
- 3
ret_cat[cat.id] = if cat.icon.present? then view_context.image_path(cat.icon.url) else "" end
end
- 1
render json: ret_cat
end
- 1
def ideas
end
- 1
def about
end
- 1
def user_info
- 1
@user = User.find(current_user.id)
- 1
authorize! :read, @user
end
- 1
def steering_home
- 2
unless user_has_steering_access? # prevent residents and artists from seeing
- 1
flash[:error] = (t 'common.authorization_error')
- 1
redirect_to root_path
end
end
- 1
def artist_home
- 2
unless user_signed_in? # prevent residents from seeing
- 1
flash[:error] = (t 'common.authorization_error')
- 1
redirect_to root_path
end
end
end
- 1
class ProposalCommentsController < ApplicationController
- 1
load_and_authorize_resource
- 1
before_action :locate_proposal
- 1
def index
- 2
@proposal_comments = @proposal.proposal_comments
end
- 1
def new
end
- 1
def create
- 3
@proposal_comment = @proposal.proposal_comments.create(proposal_comment_params)
- 3
@proposal_comment.user_id = current_user.id if current_user
- 3
if @proposal_comment.save
- 2
flash[:notice] = (t 'proposal_comments.save_success')
else
- 1
flash[:error] = (t 'proposal_comments.save_error')
end
- 3
redirect_to proposal_path(@proposal)
end
- 1
def edit
- 1
locate_comment
end
- 1
def show
- 1
locate_comment
end
- 1
def update
- 4
locate_comment
- 4
if @proposal_comment.update proposal_comment_params
- 3
flash[:notice] = (t 'proposal_comments.save_success')
else
- 1
flash[:error] = (t 'proposal_comments.save_error')
end
- 4
redirect_to proposal_path(@proposal)
end
- 1
def destroy
- 3
locate_comment
- 3
if @proposal_comment.destroy
- 3
flash[:notice] = (t 'proposal_comments.remove_success')
else
flash[:error] = (t 'proposal_comments.remove_error')
end
- 3
redirect_to proposal_path(@proposal)
end
- 1
private
- 1
def proposal_comment_params
- 19
params.require(:proposal_comment).permit(:body)
end
- 1
def locate_proposal
- 14
@proposal = Proposal.find(params[:proposal_id])
end
- 1
def locate_comment
- 9
@proposal_comment = @proposal.proposal_comments.find(params[:id])
end
end
- 1
class ProposalsController < ApplicationController
- 1
load_and_authorize_resource
- 1
def index
- 13
@proposals = @proposals.where(:iteration_id => Iteration.get_current.id)
.paginate :page => params[:page], :per_page => 25
- 13
if params[:sort].present?
- 6
if params[:sort] == "cost"
- 1
@proposals = @proposals.includes(:proposal_budget).order("proposal_budgets.cost")
elsif params[:sort] == "votes"
- 1
if user_has_steering_access? # prevent non-privileged members from sorting by votes
- 1
@proposals = @proposals.left_joins(:votes).group(:id).order("count(votes.id) desc")
end
elsif params[:sort] == "first_name"
- 1
@proposals = @proposals.includes(:user).order("users.first_name")
elsif params[:sort] == "last_name"
- 1
@proposals = @proposals.includes(:user).order("users.last_name")
elsif params[:sort] == "date"
- 1
@proposals = @proposals.order("created_at desc")
elsif ["title", "id"].include? params[:sort]
- 1
@proposals = @proposals.order params[:sort]
end
end
- 13
if params[:status].present?
- 1
@proposals = @proposals.where(status: Proposal.statuses[params[:status]])
end
- 13
index_respond @proposals, :proposals
end
- 1
alias_method :card_index, :index
- 1
def new
- 2
@proposal.build_proposal_budget
end
- 1
def edit
end
- 1
def create
- 4
@proposal = Proposal.new proposal_params
# @proposal.build_proposal_budget
- 4
@proposal.user_id = current_user.id
- 4
@proposal.iteration_id = Iteration.get_current.id
- 4
@submitter = @proposal.user
- 4
@to = @submitter.email
- 4
if @proposal.save
- 3
flash[:notice] = (t 'proposals.save_success')
- 3
flash[:notice] = (t 'proposals.save_success')
- 3
SlpMailer.email_custom_text(@to, (t 'proposals.thanks_subject', :name => @submitter.first_name),
- 6
(t 'proposals.thanks_body', :name => @submitter.first_name)).deliver
- 3
redirect_to proposals_path
else
- 1
flash[:error] = (t 'proposals.save_error')
- 1
render 'new'
end
end
- 1
def show
end
- 1
def destroy
- 3
@proposal.proposal_comments.destroy_all # remove all associated comments
- 3
@proposal.destroy
- 3
redirect_to proposals_path
end
- 1
def update
- 9
if @proposal.update proposal_params
- 8
redirect_to @proposal
else
- 1
render 'edit'
end
end
- 1
def approve
- 2
@proposal = Proposal.find(params[:id])
- 2
if @proposal.approved?
- 1
@proposal.unchecked!
else
- 1
@proposal.approved!
- 1
@creator = @proposal.user
- 1
@to = @creator.email
SlpMailer.email_custom_text(@to, "Your proposal was approved<EMAIL_ADDRESS>- 1
"Congrats<EMAIL_ADDRESS>Your proposal was approved by PauseLab and will be shown publicly!").deliver
end
- 2
@proposal.save
- 2
render 'show'
end
- 1
def fund
- 2
@proposal = Proposal.find(params[:id])
- 2
if @proposal.funded?
- 1
@proposal.approved!
else
- 1
@proposal.funded!
end
- 2
@proposal.save
- 2
render 'show'
end
- 1
private
- 1
def proposal_params
- 32
params.require(:proposal).permit(
:title,
:description,
:category_id,
:essay,
:website_link,
:artist_cv,
{:proposal_budget_attributes => [
:artist_fees,
:project_materials,
:printing,
:marketing,
:documentation,
:volunteers,
:insurance,
:events
]}
)
end
#def filter_proposal_columns proposals
# unless user_has_admin_access?
# return proposals.select(:id,:cost,:description,:essay,:created_at,:updated_at,:website_link,:title)
# end
# return proposals
#end
end
- 1
class VotesController < ApplicationController
- 1
load_and_authorize_resource
- 1
def index
- 3
@votes = @votes.where(:iteration_id => Iteration.get_current.id)
.paginate :page => params[:page], :per_page => 25
- 3
index_respond @votes, :votes
end
- 1
def new
end
- 1
def create
- 4
@vote = Vote.new(vote_params)
- 4
@vote.iteration_id = Iteration.get_current.id
- 4
if (user_has_admin_access? or verify_recaptcha model: @vote, attribute: :proposals) and @vote.save
- 3
flash[:notice] = (t 'votes.save_success')
- 3
redirect_to root_path
else
- 1
flash[:error] = (t 'votes.save_error')
- 1
render 'new'
end
end
- 1
def destroy
- 2
if @vote.destroy
- 2
flash[:notice] = (t 'votes.remove_success')
else
flash[:error] = (t 'votes.remove_error')
end
- 2
redirect_to votes_path
end
- 1
private
- 1
def vote_params
- 12
params.require(:vote).permit(
:first_name,
:last_name,
:phone,
:email,
:street,
:city,
:state,
:zip_code,
:proposal_ids => []
)
end
end
- 1
module AdminHelper
end
- 1
module ApplicationHelper
- 1
def bootstrap_class_for flash_type
{
"success" => "alert-success",
"error" => "alert-danger",
"alert" => "alert-warning",
"notice" => "alert-info"
- 1
}[flash_type] || flash_type.to_s
# key = { success: "alert-success", error: "alert-danger", alert: "alert-warning", notice: "alert-info" }[flash_type]
# return key
end
# def javascript_exists?(script)
# script = "#{Rails.root}/app/assets/javascripts/#{script}.js"
# extensions = %w(.coffee .erb .coffee.erb) + [""]
# extensions.inject(false) do |truth, extension|
# truth || File.exists?("#{script}#{extension}")
# end
# end
- 1
def flash_messages(opts = {})
- 7
flash.each do |msg_type, message|
- 1
concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)} fade in") do
- 1
concat content_tag(:button, 'x', class: "close", data: { dismiss: 'alert' })
- 1
concat message
end)
end
nil
end
end
- 1
module BlogsHelper
end
- 1
module CategoriesHelper
end
- 1
module IdeasHelper
end
- 1
module LandingpagesHelper
end
- 1
module MassEmailsHelper
end
- 1
module PagesHelper
end
- 1
module ProposalCommentsHelper
end
- 1
module ProposalsHelper
# def get_static_map idea
# url = "https://maps.googleapis.com/maps/api/staticmap?"
# url += "center=#{idea.lat},#{idea.lng}&"
# url += "zoom=17&"
# url += "scale=2&"
# url += "size=600x300&"
# url += "markers=color:red%7C#{idea.lat},#{idea.lng}&"
# url += "key=#{ENV['GOOGLE_API_KEY']}"
# end
end
- 1
module VotesHelper
end
- 1
class ApplicationMailer < ActionMailer::Base
- 1
default from: '"PauseLab"<EMAIL_ADDRESS>- 1
layout 'mailer'
end
- 1
class SlpMailer < ApplicationMailer
- 1
default from: '"PauseLab"<EMAIL_ADDRESS>- 1
def email_custom_text(to, subj, body)
- 11
mail(to: to,
subject: subj,
body: body)
end
- 1
def email_custom_text_bcc(bcc, subj, body)
- 2
mail(bcc: bcc,
subject: subj,
body: body)
end
- 1
def email_custom_html(to, subj, body)
mail(to: to,
subject: subj,
body: body,
content_type: "text/html")
end
end
- 1
class Ability
- 1
include CanCan::Ability
- 1
def initialize(user)
- 200
user ||= User.new
- 200
can :manage, user # any user can manage its own data
# define aliases
- 200
alias_action :card_index, :to => :read
- 200
alias_action :create, :read, :update, :destroy, :to => :crud
- 200
if user.admin?
- 168
can :manage, :all
elsif user.moderator?
- 1
can :manage, [Blog, Category, Idea, Proposal, ProposalBudget, \
MassEmail, Vote, ProposalComment, Landingpage, Iteration]
elsif user.steerer?
- 3
can :create, [Blog, Proposal, ProposalBudget, ProposalComment, Idea, Vote]
- 3
can :read, [Blog, Category, Idea, Proposal, ProposalBudget, ProposalComment, Vote, Iteration]
- 3
can :like, Idea
- 3
cannot [:read, :like], Idea, status: Idea.statuses[:unchecked]
- 3
can :crud, Blog, user: user
- 3
can :crud, ProposalComment, user: user
- 3
can :crud, Proposal, user: user
elsif user.super_artist?
- 2
can :create, [Blog, Proposal, ProposalBudget, Idea, Vote]
- 2
can :read, [Blog, Category, Idea, Proposal, ProposalBudget]
- 2
can :like, Idea
- 2
cannot :read, Proposal, status: Proposal.statuses[:unchecked]
- 2
cannot [:read, :like], Idea, status: Idea.statuses[:unchecked]
- 2
can :crud, Blog, user: user
- 2
can :crud, Proposal, user: user
elsif user.artist?
- 6
can :create, [Proposal, ProposalBudget, Idea, Vote]
- 6
can :read, [Blog, Category, Idea, Proposal, ProposalBudget]
- 6
can :like, Idea
- 6
cannot :read, Proposal, status: Proposal.statuses[:unchecked]
- 6
cannot [:read, :like], Idea, status: Idea.statuses[:unchecked]
- 6
can :crud, Proposal, user: user
else # resident
- 20
can :create, [Idea, Vote]
- 20
can :read, [Blog, Category, Idea, Proposal, ProposalBudget]
- 20
can :like, Idea
- 20
cannot :read, Proposal, status: Proposal.statuses[:unchecked]
- 20
cannot [:read, :like], Idea, status: Idea.statuses[:unchecked]
end
# adjust permissions based on phase
- 200
unless user.admin? or user.moderator?
- 31
unless Iteration.get_current.voting?
- 29
cannot :manage, Vote # voting not allowed unless we are in the phase
end
- 31
unless Iteration.get_current.proposals?
- 29
cannot :create, Proposal # cannot create proposal unless in proposal collection phase
end
- 31
unless Iteration.get_current.ideas?
- 4
cannot :create, Idea # cannot create idea unless in idea collection phase
end
end
end
end
- 1
class ApplicationRecord < ActiveRecord::Base
- 1
self.abstract_class = true
# credit http://stackoverflow.com/a/36335591
- 1
def self.human_enum_name(enum_name, enum_value)
- 12
I18n.t("activerecord.attributes.#{model_name.i18n_key}.#{enum_name.to_s.pluralize}.#{enum_value}")
end
- 1
protected
- 1
def self.gen_csv attributes
- 10
CSV.generate(headers:true) do |csv|
- 10
csv << attributes
- 10
all.each do |obj|
csv << attributes.map do |attribute|
- 6
obj.send(attribute)
- 1
end
end
end
end
end
- 1
class Blog < ApplicationRecord
- 1
belongs_to :user
- 1
belongs_to :iteration
- 1
validates :title, :body, presence: true
- 1
def self.to_csv options={}
- 1
self.gen_csv %w{id created_at title body author_name}
end
- 1
def author_name
- 1
user.fullname
end
- 1
def preview
- 1
require 'sanitize'
- 1
Sanitize.fragment body
end
end
- 1
class Category < ApplicationRecord
- 1
has_many :ideas
- 1
validates :name, presence: true
- 1
has_attached_file :icon,
:default_url => "/images/default_icon_small.png"
- 1
validates_attachment_content_type :icon, content_type: /\Aimage\/.*\z/
- 1
def self.to_csv options={}
- 1
self.gen_csv %w{id created_at name}
end
- 1
def to_s
- 1
name
end
end
- 1
class Idea < ApplicationRecord
- 1
belongs_to :category
- 1
belongs_to :iteration
- 1
validates :first_name, :last_name, :phone, :email, :description, :address, :lat, :lng, :category_id, presence: true
- 1
validates :phone, length: { is: 10 }
- 1
validates :email, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }
- 1
enum status: [:unchecked, :approved]
- 1
enum medium: [:online, :paper]
- 1
def self.to_csv is_admin: false
- 2
if is_admin
- 2
self.gen_csv %w{id created_at description category_name likes lat lng address author phone email status medium}
else
self.gen_csv %w{id created_at description category_name likes lat lng address}
end
end
- 1
after_initialize :set_default_medium, :if => :new_record?
- 1
def set_default_medium
- 80
self.medium ||= :online
end
# only keep numbers in phone before validation. credit http://stackoverflow.com/a/28621417
- 1
before_validation :format_phone_number
- 1
def format_phone_number
- 80
self.phone.gsub!(/[^0-9]/, '')
end
- 1
def author
- 1
if self.respond_to? :first_name and self.respond_to? :last_name
- 1
"#{first_name} #{last_name}"
else
""
end
end
- 1
def category_name
- 1
category.name
end
end
- 1
class Iteration < ApplicationRecord
- 1
has_many :ideas
- 1
has_many :blogs
- 1
has_many :proposals
- 1
has_many :votes
# enum status: [:ideas, :proposals, :voting, :progress, :ended].freeze
# removed :progress as a phase as blogs are independent with the PB cycles
- 1
enum status: [:ideas, :proposals, :voting, :ended].freeze
- 1
def self.get_current
- 181
if Iteration.exists?
- 174
Iteration.last
else
- 7
iter = Iteration.new
- 7
iter.save
- 7
iter
end
end
- 1
def change_status(new_status)
- 6
self.status = new_status
end
- 1
def get_interval
- 2
if ended.nil?
- 1
"#{created_at.strftime('%x')} -- ..."
else
- 1
"#{created_at.strftime('%x')} -- #{ended.strftime('%x')}"
end
end
end
- 1
class Landingpage < ApplicationRecord
- 1
require 'sanitize'
- 1
before_save :sanitize_description
- 1
validates :title, :description, presence: true
- 1
validates :title, uniqueness: true
- 1
enum title: [:about, :artist_home, :steering_home, :ideas_home, :calling_artists, :voting_instructions, :proposal_instructions]
- 1
def sanitize_description
- 20
Sanitize.fragment(description, Sanitize::Config::RELAXED)
end
- 1
def self.to_csv options={}
- 1
self.gen_csv %w{id created_at title description}
end
end
- 1
class MassEmail < ApplicationRecord
- 1
validates :to, :subject, :body, presence: true
- 1
def self.to_csv options={}
- 1
self.gen_csv %w{id created_at to subject body}
end
end
- 1
class Proposal < ApplicationRecord
- 1
belongs_to :user
- 1
belongs_to :iteration
- 1
belongs_to :category
- 1
has_many :proposal_comments, dependent: :destroy
- 1
has_one :proposal_budget, dependent: :destroy
- 1
has_and_belongs_to_many :votes, :dependent => :delete_all
- 1
accepts_nested_attributes_for :proposal_budget
- 1
has_attached_file :artist_cv
- 1
validates_attachment :artist_cv, content_type: { content_type: ['application/pdf'] }
- 1
validates :title, :essay, :description, :category_id, presence:true
- 1
enum status: [:unchecked, :approved, :funded]
- 1
def self.to_csv is_admin: false
- 2
if is_admin
- 2
self.gen_csv %w{id created_at title description essay total_cost author_name website_link comment_history_to_s number_of_votes status}
else
self.gen_csv %w{id created_at title description essay total_cost author_name website_link status}
end
end
- 1
def total_cost
- 1
proposal_budget.cost
end
- 1
def author_name
- 1
user.fullname
end
# the following fields should only be exposed to admins
- 1
def number_of_votes
- 1
self.votes.size
end
- 1
def comment_history_to_s
- 3
proposal_comments.map {|comment| "#{comment.user.fullname}: #{comment.body}"}.join("; ")
end
end
- 1
class ProposalBudget < ApplicationRecord
- 1
before_save :find_total
- 1
belongs_to :proposal
- 1
validates :artist_fees, :project_materials, :printing, :marketing, :documentation, :volunteers, :insurance, :events, presence: true
- 1
private
- 1
def find_total
- 278
self.cost =
self.artist_fees +
self.project_materials +
self.printing +
self.marketing +
self.documentation +
self.volunteers +
self.insurance +
self.events
end
end
- 1
class ProposalComment < ApplicationRecord
- 1
belongs_to :proposal
- 1
belongs_to :user
- 1
validates :body, presence: true
end
- 1
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
- 1
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# user avatar
- 1
has_attached_file :avatar,
:styles => { :medium => "300x300#", :thumb => "100x100#" },
:default_url => "/images/:style/missing.png"
- 1
validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
- 1
validates_attachment_size :avatar, :less_than => 5.megabytes
- 1
validates :first_name, :last_name, :email, presence: true
- 1
validates :password, presence: true, :if => :password_required?
- 1
validates :email, uniqueness: true
- 1
has_many :proposals, dependent: :destroy
- 1
has_many :proposal_comments, dependent: :destroy
- 1
has_many :blogs, dependent: :destroy
# enumeration of user roles -- if adding more, be sure to modify order_roles below
- 1
enum role: [:admin, :steerer, :artist, :moderator, :resident, :super_artist]
# prioritize values from the enum so they present in the given order on a form
- 1
def self.order_roles(roles)
return [
'admin',
'moderator',
'steerer',
'super_artist',
'artist',
'resident',
- 7
].select{|r| roles.include? r.to_s }
end
- 1
def self.roles_ordered
- 1
return User.order_roles(User.roles.keys.to_a)
end
- 1
def change_role(new_role)
- 526
self.role = new_role
end
- 1
after_initialize :set_default_role, :if => :new_record?
- 1
def set_default_role
- 552
self.role ||= :resident
end
- 1
def fullname
- 5
"#{first_name} #{last_name}"
end
- 1
def self.to_csv options={}
- 1
self.gen_csv %w{id created_at fullname email phone role}
end
# taken from http://stackoverflow.com/a/7156008
- 1
def self.valid_attribute?(attr, value)
- 2
mock = self.new(attr => value)
- 2
if mock.valid?
true
else
# for some reason has_key fails, so loop manually
- 2
mock.errors.keys.each do |e|
- 6
if e.to_s == attr.to_s
- 1
return false
end
end
- 1
true
end
end
- 1
def update_attributes_manual(attrs)
- 2
success = true
- 2
attrs.each do |k, v|
- 2
if k.to_s == 'email' && v.to_s == self.email
next # otherwise email fails uniqueness check
end
- 2
success = success && (User.valid_attribute? k, v)
end
- 2
if success
- 1
attrs.each do |k, v|
- 1
success = success && (self.update_attribute k, v)
end
end
- 2
success
end
end
- 1
class Vote < ApplicationRecord
- 1
has_and_belongs_to_many :proposals
- 1
belongs_to :iteration
- 1
validates :first_name, :last_name, :phone, :email, :street, :city, :state, :zip_code, presence: true
- 1
validates :phone, length: { is: 10 }
- 1
validates :email, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }
- 1
validates :state, format: { with: /\A[a-zA-Z]{2}\z/ }
- 1
validates :zip_code, format: { with: /\A[0-9-]+\z/ }
# only keep numbers in phone before validation. credit http://stackoverflow.com/a/28621417
- 1
before_validation :format_phone_number
- 1
def format_phone_number
- 26
unless self.phone.nil?
- 26
self.phone.gsub!(/[^0-9]/, '')
end
end
- 1
validate :validate_proposals
- 1
def validate_proposals
- 26
errors.add(:proposals, :proposal_count) if proposals.size < 3
end
- 1
def author
- 1
"#{first_name} #{last_name}"
end
- 1
def address
- 1
"#{street}, #{city}, #{state}, #{zip_code}"
end
- 1
def self.to_csv options={}
- 1
self.gen_csv %w{id created_at first_name last_name phone email street city state zip_code}
end
end
- 1
require_relative 'boot'
- 1
require 'csv'
- 1
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
- 1
Bundler.require(*Rails.groups)
- 1
module Pauselab
- 1
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
- 1
config.time_zone = 'Eastern Time (US & Canada)'
- 1
config.active_record.default_timezone = :local # Or :utc
end
end
- 1
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
- 1
require 'bundler/setup' # Set up gems listed in the Gemfile.
# Load the Rails application.
- 1
require_relative 'application'
# Initialize the Rails application.
- 1
Rails.application.initialize!
- 1
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
- 1
config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
- 1
config.eager_load = false
# Configure public file server for tests with Cache-Control for performance.
- 1
config.public_file_server.enabled = true
- 1
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=3600'
}
# Show full error reports and disable caching.
- 1
config.consider_all_requests_local = true
- 1
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates.
- 1
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
- 1
config.action_controller.allow_forgery_protection = false
- 1
config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
- 1
config.action_mailer.delivery_method = :test
# Print deprecation notices to the stderr.
- 1
config.active_support.deprecation = :stderr
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end
# Be sure to restart your server when you modify this file.
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
- 1
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
- 1
Rails.application.config.assets.precompile += %w( admin.js )
- 1
Rails.application.config.assets.precompile += %w( blogs.js )
- 1
Rails.application.config.assets.precompile += %w( proposals.js )
- 1
Rails.application.config.assets.precompile += %w( proposal_comments.js )
- 1
Rails.application.config.assets.precompile += %w( landingpages.js )
- 1
Rails.application.config.assets.precompile += %w( mass_emails.js )
- 1
Rails.application.config.assets.precompile += %w( ideas.js )
- 1
Rails.application.config.assets.precompile += %w( pages.js )
- 1
Rails.application.config.assets.precompile += %w( votes.js )
- 1
Rails.application.config.assets.precompile += %w( categories.js )
- 1
Rails.application.config.assets.precompile += %w( admin/users.js )
- 1
Rails.application.config.assets.precompile += %w( instafeed.min.js )
- 1
Rails.application.config.assets.precompile += %w( devise/sessions.js )
- 1
Rails.application.config.assets.precompile += %w( devise/passwords.js )
- 1
Rails.application.config.assets.precompile += %w( users/registrations.js )
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!
- 1
module SimpleForm
- 1
module Inputs
- 1
class FileInput < Base
- 1
def input(wrapper_options)
- 2
button_text = options[:button_text] || (t 'common.browse')
- 2
idf = "#{lookup_model_names.join("_")}_#{reflection_or_attribute_name}"
- 2
input_html_options[:style] ||= 'display:none;'
- 2
button = template.content_tag(:div, class: 'custom-file') do
template.tag(:input, id: "pbox_#{idf}", class: 'custom-file-input', type: 'text') +
- 2
template.content_tag(:span, button_text, class: 'custom-file-control pull-right', id: "pbox_span_#{idf}", onclick: "$('input[id=#{idf}]').click();")
end
- 2
script = template.content_tag(:script, type: 'text/javascript') do
- 2
"$('input[id=#{idf}]').change(function() { s = $(this).val(); s = s.split('\\\\').pop(); $('#pbox_span_#{idf}').html(s); });".html_safe
end
- 2
@builder.file_field(attribute_name, input_html_options) + button + script
end
end
end
end
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
- 1
Rails.application.config.action_dispatch.cookies_serializer = :json
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
- 1
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmation, reset password and unlock tokens in the database.
# Devise will use the `secret_key_base` as its `secret_key`
# by default. You can change it below and use your own secret key.
- 1
config.secret_key = Figaro.env.devise_secret_key if Rails.env.production?
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
- 1
config.mailer_sender = '"PauseLab"<EMAIL_ADDRESS># Configure the class responsible to send e-mails.
# config.mailer = 'Devise::Mailer'
# Configure the parent class responsible to send e-mails.
# config.parent_mailer = 'ActionMailer::Base'
# ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default) and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems.
- 1
require 'devise/orm/active_record'
# ==> Configuration for any authentication mechanism
# Configure which keys are used when authenticating a user. The default is
# just :email. You can configure it to use [:username, :subdomain], so for
# authenticating a user, both parameters are required. Remember that those
# parameters are used only when authenticating and not when retrieving from
# session. If you need permissions, you should implement that in a before filter.
# You can also supply a hash where the value is a boolean determining whether
# or not authentication should be aborted when the value is not present.
# config.authentication_keys = [:email]
# Configure parameters from the request object used for authentication. Each entry
# given should be a request method and it will automatically be passed to the
# find_for_authentication method and considered in your model lookup. For instance,
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
# The same considerations mentioned for authentication_keys also apply to request_keys.
# config.request_keys = []
# Configure which authentication keys should be case-insensitive.
# These keys will be downcased upon creating or modifying a user and when used
# to authenticate or find a user. Default is :email.
- 1
config.case_insensitive_keys = [:email]
# Configure which authentication keys should have whitespace stripped.
# These keys will have whitespace before and after removed upon creating or
# modifying a user and when used to authenticate or find a user. Default is :email.
- 1
config.strip_whitespace_keys = [:email]
# Tell if authentication through request.params is enabled. True by default.
# It can be set to an array that will enable params authentication only for the
# given strategies, for example, `config.params_authenticatable = [:database]` will
# enable it only for database (email + password) authentication.
# config.params_authenticatable = true
# Tell if authentication through HTTP Auth is enabled. False by default.
# It can be set to an array that will enable http authentication only for the
# given strategies, for example, `config.http_authenticatable = [:database]` will
# enable it only for database authentication. The supported strategies are:
# :database = Support basic authentication with authentication key + password
# config.http_authenticatable = false
# If 401 status code should be returned for AJAX requests. True by default.
# config.http_authenticatable_on_xhr = true
# The realm used in Http Basic Authentication. 'Application' by default.
# config.http_authentication_realm = 'Application'
# It will change confirmation, password recovery and other workflows
# to behave the same regardless if the e-mail provided was right or wrong.
# Does not affect registerable.
# config.paranoid = true
# By default Devise will store the user in session. You can skip storage for
# particular strategies by setting this option.
# Notice that if you are skipping storage for all authentication paths, you
# may want to disable generating routes to Devise's sessions controller by
# passing skip: :sessions to `devise_for` in your config/routes.rb
- 1
config.skip_session_storage = [:http_auth]
# By default, Devise cleans up the CSRF token on authentication to
# avoid CSRF token fixation attacks. This means that, when using AJAX
# requests for sign in and sign up, you need to get a new CSRF token
# from the server. You can disable this option at your own risk.
# config.clean_up_csrf_token_on_authentication = true
# When false, Devise will not attempt to reload routes on eager load.
# This can reduce the time taken to boot the app but if your application
# requires the Devise mappings to be loaded during boot time the application
# won't boot properly.
# config.reload_routes = true
# ==> Configuration for :database_authenticatable
# For bcrypt, this is the cost for hashing the password and defaults to 11. If
# using other algorithms, it sets how many times you want the password to be hashed.
#
# Limiting the stretches to just one in testing will increase the performance of
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
# a value less than 10 in other environments. Note that, for bcrypt (the default
# algorithm), the cost increases exponentially with the number of stretches (e.g.
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
- 1
config.stretches = Rails.env.test? ? 1 : 11
# Set up a pepper to generate the hashed password.
# config.pepper = '4782831688b64bd7b8f05923cced5e7af8b2f9a806b7decb1f90cbc8e7d5ad2c87d12108ee2fca8e2a085dbba8bfab4f0536e3433c3cd2c0aa14098d1e33dc94'
# Send a notification email when the user's password is changed
# config.send_password_change_notification = false
# ==> Configuration for :confirmable
# A period that the user is allowed to access the website even without
# confirming their account. For instance, if set to 2.days, the user will be
# able to access the website for two days without confirming their account,
# access will be blocked just in the third day. Default is 0.days, meaning
# the user cannot access the website without confirming their account.
# config.allow_unconfirmed_access_for = 2.days
# A period that the user is allowed to confirm their account before their
# token becomes invalid. For example, if set to 3.days, the user can confirm
# their account within 3 days after the mail was sent, but on the fourth day
# their account can't be confirmed with the token any more.
# Default is nil, meaning there is no restriction on how long a user can take
# before confirming their account.
# config.confirm_within = 3.days
# If true, requires any email changes to be confirmed (exactly the same way as
# initial account confirmation) to be applied. Requires additional unconfirmed_email
# db field (see migrations). Until confirmed, new email is stored in
# unconfirmed_email column, and copied to email column on successful confirmation.
- 1
config.reconfirmable = true
# Defines which key will be used when confirming an account
# config.confirmation_keys = [:email]
# ==> Configuration for :rememberable
# The time the user will be remembered without asking for credentials again.
# config.remember_for = 2.weeks
# Invalidates all the remember me tokens when the user signs out.
- 1
config.expire_all_remember_me_on_sign_out = true
# If true, extends the user's remember period when remembered via cookie.
# config.extend_remember_period = false
# Options to be passed to the created cookie. For instance, you can set
# secure: true in order to force SSL only cookies.
# config.rememberable_options = {}
# ==> Configuration for :validatable
# Range for password length.
- 1
config.password_length = 6..128
# Email regex used to validate email formats. It simply asserts that
# one (and only one) @ exists in the given string. This is mainly
# to give user feedback and not to assert the e-mail validity.
- 1
config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
# ==> Configuration for :timeoutable
# The time you want to timeout the user session without activity. After this
# time the user will be asked for credentials again. Default is 30 minutes.
# config.timeout_in = 30.minutes
# ==> Configuration for :lockable
# Defines which strategy will be used to lock an account.
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
# :none = No lock strategy. You should handle locking by yourself.
# config.lock_strategy = :failed_attempts
# Defines which key will be used when locking and unlocking an account
# config.unlock_keys = [:email]
# Defines which strategy will be used to unlock an account.
# :email = Sends an unlock link to the user email
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
# :both = Enables both strategies
# :none = No unlock strategy. You should handle unlocking by yourself.
# config.unlock_strategy = :both
# Number of authentication tries before locking an account if lock_strategy
# is failed attempts.
# config.maximum_attempts = 20
# Time interval to unlock the account if :time is enabled as unlock_strategy.
# config.unlock_in = 1.hour
# Warn on the last attempt before the account is locked.
# config.last_attempt_warning = true
# ==> Configuration for :recoverable
#
# Defines which key will be used when recovering the password for an account
# config.reset_password_keys = [:email]
# Time interval you can reset your password with a reset password key.
# Don't put a too small interval or your users won't have the time to
# change their passwords.
- 1
config.reset_password_within = 6.hours
# When set to false, does not sign a user in automatically after their password is
# reset. Defaults to true, so a user is signed in automatically after a reset.
# config.sign_in_after_reset_password = true
# ==> Configuration for :encryptable
# Allow you to use another hashing or encryption algorithm besides bcrypt (default).
# You can use :sha1, :sha512 or algorithms from others authentication tools as
# :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
# for default behavior) and :restful_authentication_sha1 (then you should set
# stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
#
# Require the `devise-encryptable` gem when using anything other than bcrypt
# config.encryptor = :sha512
# ==> Scopes configuration
# Turn scoped views on. Before rendering "sessions/new", it will first check for
# "users/sessions/new". It's turned off by default because it's slower if you
# are using only default views.
- 1
config.scoped_views = true
# Configure the default scope given to Warden. By default it's the first
# devise role declared in your routes (usually :user).
# config.default_scope = :user
# Set this configuration to false if you want /users/sign_out to sign out
# only the current scope. By default, Devise signs out all scopes.
# config.sign_out_all_scopes = true
# ==> Navigation configuration
# Lists the formats that should be treated as navigational. Formats like
# :html, should redirect to the sign in page when the user does not have
# access, but formats like :xml or :json, should return 401.
#
# If you have any extra navigational formats, like :iphone or :mobile, you
# should add them to the navigational formats lists.
#
# The "*/*" below is required to match Internet Explorer requests.
# config.navigational_formats = ['*/*', :html]
# The default HTTP method used to sign out a resource. Default is :delete.
- 1
config.sign_out_via = :delete
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
# change the failure app, you can configure them inside the config.warden block.
#
# config.warden do |manager|
# manager.intercept_401 = false
# manager.default_strategies(scope: :user).unshift :some_external_strategy
# end
# ==> Mountable engine configurations
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
# is mountable, there are some extra configurations to be taken into account.
# The following options are available, assuming the engine is mounted as:
#
# mount MyEngine, at: '/my_engine'
#
# The router that invoked `devise_for`, in the example above, would be:
# config.router_name = :my_engine
#
# When using OmniAuth, Devise cannot automatically set OmniAuth path,
# so you need to do it manually. For the users scope, it would be:
# config.omniauth_path_prefix = '/my_engine/users/auth'
end
- 1
DisqusRails.setup do |config|
- 1
config::SHORT_NAME = "becville"
- 1
config::SECRET_KEY = "" #leave blank if not used
- 1
config::PUBLIC_KEY = "" #leave blank if not used
- 1
config::ACCESS_TOKEN = "" #you got it, right? ;-)
end
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
- 1
Rails.application.config.filter_parameters += [:password]
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.0 upgrade.
#
# Read the Rails 5.0 release notes for more info on each option.
# Enable per-form CSRF tokens. Previous versions had false.
- 1
Rails.application.config.action_controller.per_form_csrf_tokens = true
# Enable origin-checking CSRF mitigation. Previous versions had false.
- 1
Rails.application.config.action_controller.forgery_protection_origin_check = true
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
# Previous versions had false.
- 1
ActiveSupport.to_time_preserves_timezone = true
# Require `belongs_to` associations by default. Previous versions had false.
- 1
Rails.application.config.active_record.belongs_to_required_by_default = true
# Do not halt callback chains when a callback returns false. Previous versions had true.
- 1
ActiveSupport.halt_callback_chains_on_return_false = false
# Configure SSL options to enable HSTS with subdomains. Previous versions had false.
- 1
Rails.application.config.ssl_options = { hsts: { subdomains: true } }
# Be sure to restart your server when you modify this file.
- 1
Rails.application.config.session_store :cookie_store, key: '_pauselab_session'
# Use this setup block to configure all options available in SimpleForm.
- 1
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a
# complete input. You can remove any component from the
# wrapper, change the order or even add your own to the
# stack. The options given below are used to wrap the
# whole input.
- 1
config.wrappers :default, class: :input,
hint_class: :field_with_hint, error_class: :field_with_errors do |b|
## Extensions enabled by default
# Any of these extensions can be disabled for a
# given input by passing: `f.input EXTENSION_NAME => false`.
# You can make any of these extensions optional by
# renaming `b.use` to `b.optional`.
# Determines whether to use HTML5 (:email, :url, ...)
# and required attributes
- 1
b.use :html5
# Calculates placeholders automatically from I18n
# You can also pass a string as f.input placeholder: "Placeholder"
- 1
b.use :placeholder
## Optional extensions
# They are disabled unless you pass `f.input EXTENSION_NAME => true`
# to the input. If so, they will retrieve the values from the model
# if any exists. If you want to enable any of those
# extensions by default, you can change `b.optional` to `b.use`.
# Calculates maxlength from length validations for string inputs
- 1
b.optional :maxlength
# Calculates pattern from format validations for string inputs
- 1
b.optional :pattern
# Calculates min and max from length validations for numeric inputs
- 1
b.optional :min_max
# Calculates readonly automatically from readonly attributes
- 1
b.optional :readonly
## Inputs
- 1
b.use :label_input
- 1
b.use :hint, wrap_with: { tag: :span, class: :hint }
- 1
b.use :error, wrap_with: { tag: :span, class: :error }
## full_messages_for
# If you want to display the full error message for the attribute, you can
# use the component :full_error, like:
#
# b.use :full_error, wrap_with: { tag: :span, class: :error }
end
# The default wrapper to be used by the FormBuilder.
- 1
config.default_wrapper = :default
# Define the way to render check boxes / radio buttons with labels.
# Defaults to :nested for bootstrap config.
# inline: input + label
# nested: label > input
- 1
config.boolean_style = :nested
# Default class for buttons
- 1
config.button_class = 'btn'
# Method used to tidy up errors. Specify any Rails Array method.
# :first lists the first message for each field.
# Use :to_sentence to list all errors for each field.
# config.error_method = :first
# Default tag used for error notification helper.
- 1
config.error_notification_tag = :div
# CSS class to add for error notification helper.
- 1
config.error_notification_class = 'error_notification'
# ID to add for error notification helper.
# config.error_notification_id = nil
# Series of attempts to detect a default label method for collection.
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
# Series of attempts to detect a default value method for collection.
# config.collection_value_methods = [ :id, :to_s ]
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
# config.collection_wrapper_tag = nil
# You can define the class to use on all collection wrappers. Defaulting to none.
# config.collection_wrapper_class = nil
# You can wrap each item in a collection of radio/check boxes with a tag,
# defaulting to :span.
# config.item_wrapper_tag = :span
# You can define a class to use in all item wrappers. Defaulting to none.
# config.item_wrapper_class = nil
# How the label text should be generated altogether with the required text.
# config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
# You can define the class to use on all labels. Default is nil.
# config.label_class = nil
# You can define the default class to be used on forms. Can be overriden
# with `html: { :class }`. Defaulting to none.
# config.default_form_class = nil
# You can define which elements should obtain additional classes
# config.generate_additional_classes_for = [:wrapper, :label, :input]
# Whether attributes are required by default (or not). Default is true.
# config.required_by_default = true
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
# These validations are enabled in SimpleForm's internal config but disabled by default
# in this configuration, which is recommended due to some quirks from different browsers.
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
# change this configuration to true.
- 1
config.browser_validations = false
# Collection of methods to detect if a file type was given.
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
# Custom mappings for input types. This should be a hash containing a regexp
# to match as key, and the input type that will be used when the field name
# matches the regexp as value.
# config.input_mappings = { /count/ => :integer }
# Custom wrappers for input types. This should be a hash containing an input
# type as key and the wrapper that will be used for all inputs with specified type.
# config.wrapper_mappings = { string: :prepend }
# Namespaces where SimpleForm should look for custom input classes that
# override default inputs.
# config.custom_inputs_namespaces << "CustomInputs"
# Default priority for time_zone inputs.
# config.time_zone_priority = nil
# Default priority for country inputs.
# config.country_priority = nil
# When false, do not use translations for labels.
# config.translate_labels = true
# Automatically discover new inputs in Rails' autoload path.
# config.inputs_discovery = true
# Cache SimpleForm inputs discovery
# config.cache_discovery = !Rails.env.development?
# Default class for inputs
# config.input_class = nil
# Define the default class of the input wrapper of the boolean input.
- 1
config.boolean_label_class = 'checkbox'
# Defines if the default input wrapper class should be included in radio
# collection wrappers.
# config.include_default_input_wrapper_class = true
# Defines which i18n scope will be used in Simple Form.
# config.i18n_scope = 'simple_form'
end
# Use this setup block to configure all options available in SimpleForm.
- 1
SimpleForm.setup do |config|
- 1
config.error_notification_class = 'alert alert-danger'
- 1
config.button_class = 'btn btn-default'
- 1
config.boolean_label_class = nil
- 1
config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
- 1
b.use :html5
- 1
b.use :placeholder
- 1
b.optional :maxlength
- 1
b.optional :pattern
- 1
b.optional :min_max
- 1
b.optional :readonly
- 1
b.use :label, class: 'control-label'
- 1
b.use :input, class: 'form-control'
- 1
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- 1
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
- 1
config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
- 1
b.use :html5
- 1
b.use :placeholder
- 1
b.optional :maxlength
- 1
b.optional :readonly
- 1
b.use :label, class: 'control-label'
- 1
b.use :input
- 1
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- 1
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
- 1
config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
- 1
b.use :html5
- 1
b.optional :readonly
- 1
b.wrapper tag: 'div', class: 'checkbox' do |ba|
- 1
ba.use :label_input
end
- 1
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- 1
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
- 1
config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
- 1
b.use :html5
- 1
b.optional :readonly
- 1
b.use :label, class: 'control-label'
- 1
b.use :input
- 1
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- 1
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
- 1
config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
- 1
b.use :html5
- 1
b.use :placeholder
- 1
b.optional :maxlength
- 1
b.optional :pattern
- 1
b.optional :min_max
- 1
b.optional :readonly
- 1
b.use :label, class: 'col-sm-3 control-label'
- 1
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
- 1
ba.use :input, class: 'form-control'
- 1
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- 1
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
- 1
config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
- 1
b.use :html5
- 1
b.use :placeholder
- 1
b.optional :maxlength
- 1
b.optional :readonly
- 1
b.use :label, class: 'col-sm-3 control-label'
- 1
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
- 1
ba.use :input
- 1
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- 1
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
- 1
config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
- 1
b.use :html5
- 1
b.optional :readonly
- 1
b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
- 1
wr.wrapper tag: 'div', class: 'checkbox' do |ba|
- 1
ba.use :label_input
end
- 1
wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- 1
wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
- 1
config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
- 1
b.use :html5
- 1
b.optional :readonly
- 1
b.use :label, class: 'col-sm-3 control-label'
- 1
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
- 1
ba.use :input
- 1
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- 1
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
- 1
config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
- 1
b.use :html5
- 1
b.use :placeholder
- 1
b.optional :maxlength
- 1
b.optional :pattern
- 1
b.optional :min_max
- 1
b.optional :readonly
- 1
b.use :label, class: 'sr-only'
- 1
b.use :input, class: 'form-control'
- 1
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- 1
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
- 1
config.wrappers :multi_select, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
- 1
b.use :html5
- 1
b.optional :readonly
- 1
b.use :label, class: 'control-label'
- 1
b.wrapper tag: 'div', class: 'form-inline' do |ba|
- 1
ba.use :input, class: 'form-control'
- 1
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- 1
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
# Wrappers for forms and inputs using the Bootstrap toolkit.
# Check the Bootstrap docs (http://getbootstrap.com)
# to learn about the different styles for forms and inputs,
# buttons and other elements.
- 1
config.default_wrapper = :vertical_form
- 1
config.wrapper_mappings = {
check_boxes: :vertical_radio_and_checkboxes,
radio_buttons: :vertical_radio_and_checkboxes,
file: :vertical_file_input,
boolean: :vertical_boolean,
datetime: :multi_select,
date: :multi_select,
time: :multi_select
}
end
- 1
SocialShareButton.configure do |config|
- 1
config.allow_sites = %w(twitter facebook)
end
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
- 1
ActiveSupport.on_load(:action_controller) do
- 2
wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end
- 1
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
# wrap routes within locale scope so it appears at top part of url
- 1
scope "(:locale)", locale: /en|es/ do
- 1
devise_for :users, controllers: { registrations: "users/registrations" }
# this will change depending on the current phase of the process
- 1
root 'pages#go_home'
# idea routes
- 1
get '/ideas/like/:id' => "ideas#like", as: 'idea_like'
- 1
post '/ideas/approve/:id', to: 'ideas#approve', as: 'idea_approve'
- 1
get '/idea_cards', to: 'ideas#card_index'
# admin routes
# NOTE admin routes and controller actions are singular for consistency
# however, it differs with the other RESTful controllers so don't get confused
- 1
get '/admin/edit_phase', to: 'admin#edit_phase'
- 1
put '/admin/edit_phase', to: 'admin#change_phase', as: 'change_phase'
- 1
get '/admin/next_phase', to: 'admin#next_phase'
- 1
get '/admin/end_phase', to: 'admin#end_phase'
- 1
get '/admin/export_zip/:num', to: 'admin#export_zip', as: 'export_zip'
- 1
get '/admin/export_iterations', to: 'admin#export_iterations'
# proposal routes
- 1
post '/proposals/approve/:id', to: 'proposals#approve', as: 'proposal_approve'
- 1
post '/proposals/fund/:id', to: 'proposals#fund', as: 'proposal_fund'
- 1
get '/proposal_cards', to: 'proposals#card_index'
# static pages routes
- 1
get '/pages/ideas', to: 'pages#ideas', as: 'ideas_home'
- 1
get '/user_info', to: 'pages#user_info', as: 'user_info'
- 1
get '/about', to: 'pages#about_page', as: 'about'
- 1
get '/artist', to: 'pages#artist_home', as: 'artist_home'
- 1
get '/steering', to: 'pages#steering_home', as: 'steering_home'
- 1
get '/pages/ideas_json', to: 'pages#get_ideas', as: 'ideas_json'
- 1
get '/pages/categories_json', to: 'pages#get_categories', as: 'categories_json'
# blogs routes
- 1
get 'blogs/admin_console', to: "blogs#admin_console", as: 'blogs_admin_console'
# makes RESTful routes for our models
- 1
resources :ideas, :categories, :blogs, :mass_emails, :votes, :landingpages
- 1
resources :proposals do
- 1
resources :proposal_comments
end
- 1
namespace :admin do
- 1
resources :users
end
end
end


--- title: Edit My Profile ---
Allowed JPG, GIF or PNG. Max size of 800kB
Your email is not confirmed. Please check your inbox.


pagePiling.js
Create an original scrolling site
jQuery plugin
Pile your sections one over another and access them scrolling or by URL!
Slide 2.2
Slide 2.3
jQuery plugin
Pile your sections one over another and access them scrolling or by URL!
Slide 3.2
Slide 3.3
Compatible
Designed to work on tablet and mobile devices.
Oh! And its compatible with old browsers such as IE 8 or Opera 12!


THB_WetBulbTemperature
Path: CARNOT/Basic/Material_Properties
Purpose
The function calculates
the wet bulb temperature.
Description
The function uses a
look-up table created by the function rel_hum2x to calculate the wet bulb
temperature in °C of moist air according to the
Inputs:
This block is only useful in the case of moist air (fluid type 2, fluid mix 0)
Characteristics
Direct Feedthrough Yes
Sample
time
Inherited
from driving block
Vectorized
No


--- layout: post title: "An example of state-based testing in Haskell" description: "How do you do state-based testing when state is immutable? You use the State monad." date: 2019-03-11 7:55 UTC tags: [Unit Testing, Haskell] --- {% include JB/setup %}
{{ page.description }}
This article is an instalment in an article series about how to move from interaction-based testing to state-based testing. In the previous article, you saw an example of an interaction-based unit test written in C#. The problem that this article series attempts to address is that interaction-based testing can lead to what xUnit Test Patterns calls Fragile Tests, because the tests get coupled to implementation details, instead of overall behaviour.
My experience is that functional programming is better aligned with unit testing because functional design is intrinsically testable. While I believe that functional programming is no panacea, it still seems to me that we can learn many valuable lessons about programming from it.
People often ask me about F# programming: How do I know that my F# code is functional?
I sometimes wonder that myself, about my own F# code. One can certainly choose to ignore such a question as irrelevant, and I sometimes do, as well. Still, in my experience, asking such questions can create learning opportunities.
The best answer that I've found is: Port the F# code to Haskell.
Haskell enforces referential transparency via its compiler. If Haskell code compiles, it's functional. In this article, then, I take the problem from the previous article and port it to Haskell.
The code shown in this article is available on GitHub.
In the previous article, you saw implementation and test coverage of a piece of software functionality to connect two users with each other. This was a simplification of the example running through my two Clean Coders videos, Church Visitor and Preserved in translation.
In contrast to the previous article, we'll start with the implementation of the System Under Test (SUT).
post :: Monad m => (a -> m (Either UserLookupError User)) -> (User -> m ()) -> a -> a -> m (HttpResponse User) post lookupUser updateUser userId otherUserId = do userRes <- first (\case InvalidId -> "Invalid user ID." NotFound -> "User not found.") <$> lookupUser userId otherUserRes <- first (\case InvalidId -> "Invalid ID for other user." NotFound -> "Other user not found.") <$> lookupUser otherUserId connect <- runExceptT $ do user <- ExceptT $ return userRes otherUser <- ExceptT $ return otherUserRes lift $ updateUser $ addConnection user otherUser return otherUser return $ either BadRequest OK connect
This is as direct a translation of the C# code as makes sense. If I'd only been implementing the desired functionality in Haskell, without having to port existing code, I'd designed the code differently.
This post
function uses partial application as an analogy to dependency injection, but in order to enable potentially impure operations to take place, everything must happen inside of some monad. While the production code must ultimately run in the IO
monad in order to interact with a database, tests can choose to run in another monad.
In the C# example, two dependencies are injected into the class that defines the Post
method. In the above Haskell function, these two dependencies are instead passed as function arguments. Notice that both functions return values in the monad m
.
The intent of the lookupUser
argument is that it'll query a database with a user ID. It'll return the user if present, but it could also return a UserLookupError
, which is a simple sum type:
data UserLookupError = InvalidId | NotFound deriving (Show, Eq)
If both users are found, the function connects the users and calls the updateUser
function argument. The intent of this 'dependency' is that it updates the database. This is recognisably a Command, since its return type is m ()
- unit (()
) is equivalent to void
.
How do you unit test such a function? How do you use Mocks and Stubs in Haskell? You don't; you don't have to. While the post
method can be impure (when m
is IO
), it doesn't have to be. Functional design is intrinsically testable, but that proposition depends on purity. Thus, it's worth figuring out how to keep the post
function pure in the context of unit testing.
While IO
implies impurity, most common monads are pure. Which one should you choose? You could attempt to entirely 'erase' the monadic quality of the post
function with the Identity
monad, but if you do that, you can't verify whether or not updateUser
was invoked.
While you could write an ad-hoc Mock using, for example, the Writer
monad, it might be a better choice to investigate if something closer to state-based testing would be possible.
In an object-oriented context, state-based testing implies that you exercise the SUT, which mutates some state, and then you verify that the (mutated) state matches your expectations. You can't do that when you test a pure function, but you can examine the state of the function's return value. The State
monad is an obvious choice, then.
Haskell's State
monad is parametrised on the state type as well as the normal 'value type', so in order to be able to test the post
function, you'll have to figure out what type of state to use. The interactions implied by the post
function's lookupUser
and updateUser
arguments are those of database interactions. A Fake database seems an obvious choice.
For the purposes of testing the post
function, an in-memory database implemented using a Map
is appropriate:
type DB = Map Integer User
This is simply a dictionary keyed by Integer
values and containing User
values. You can implement compatible lookupUser
and updateUser
functions with State DB
as the Monad
. The updateUser
function is the easiest one to implement:
updateUser :: User -> State DB () updateUser user = modify $ Map.insert (userId user) user
This simply inserts the user
into the database, using the userId
as the key. The type of the function is compatible with the general requirement of User -> m ()
, since here, m
is State DB
.
The lookupUser
Fake implementation is a bit more involved:
lookupUser :: String -> State DB (Either UserLookupError User) lookupUser s = do let maybeInt = readMaybe s :: Maybe Integer let eitherInt = maybe (Left InvalidId) Right maybeInt db <- get return $ eitherInt >>= maybe (Left NotFound) Right . flip Map.lookup db
First, consider the type. The function takes a String
value as an argument and returns a State DB (Either UserLookupError User)
. The requirement is a function compatible with the type a -> m (Either UserLookupError User)
. This works when a
is String
and m
is, again, State DB
.
The entire function is written in do
notation, where the inferred Monad
is, indeed, State DB
. The first line attempts to parse the String
into an Integer
. Since the built-in readMaybe
function returns a Maybe Integer
, the next line uses the maybe
function to handle the two possible cases, converting the Nothing
case into the Left InvalidId
value, and the Just
case into a Right
value.
It then uses the State
module's get
function to access the database db
, and finally attempt a lookup
against that Map
. Again, maybe
is used to convert the Maybe
value returned by Map.lookup
into an Either
value.
This is all you need in terms of Test Doubles. You now have test-specific lookupUser
and updateUser
functions that you can pass to the post
function.
Like in the previous article, you can start by exercising the happy path where a user successfully connects with another user:
testProperty "Users successfully connect" $ \ user otherUser -> runStateTest $ do put $ Map.fromList [toDBEntry user, toDBEntry otherUser] actual <- post lookupUser updateUser (show $ userId user) (show $ userId otherUser) db <- get return $ isOK actual && any (elem otherUser . connectedUsers) (Map.lookup (userId user) db)
Here I'm inlining test cases as anonymous functions - this time expressing the tests as QuickCheck properties. I'll later return to the runStateTest
helper function, but first I want to focus on the test body itself. It's written in do
notation, and specifically, it runs in the State DB
monad.
user
and otherUser
are input arguments to the property. These are both User
values, since the test also defines Arbitrary
instances for that type (not shown in this article; see the source code repository for details).
The first step in the test is to 'save' both users in the Fake database. This is easily done by converting each User
value to a database entry:
toDBEntry :: User -> (Integer, User) toDBEntry = userId &&& id
Recall that the Fake database is nothing but an alias over Map Integer User
, so the only operation required to turn a User
into a database entry is to extract the key.
The next step in the test is to exercise the SUT, passing the test-specific lookupUser
and updateUser
Test Doubles to the post
function, together with the user IDs converted to String
values.
In the assert phase of the test, it first extracts the current state of the database, using the State
library's built-in get
function. It then verifies that actual
represents a 200 OK
value, and that the user
entry in the database now contains otherUser
as a connected user.
While there's one happy-path test case, there's four other test cases left. One of these is when the first user doesn't exist:
testProperty "Users don't connect when user doesn't exist" $ \ (Positive i) otherUser -> runStateTest $ do let db = Map.fromList [toDBEntry otherUser] put db let uniqueUserId = show $ userId otherUser + i actual <- post lookupUser updateUser uniqueUserId (show $ userId otherUser) assertPostFailure db actual
What ought to trigger this test case is that the 'first' user doesn't exist, even if the otherUser
does exist. For this reason, the test inserts the otherUser
into the Fake database.
Since the test is a QuickCheck property, i
could be any positive Integer
value - including the userId
of otherUser
. In order to properly exercise the test case, however, you'll need to call the post
function with a uniqueUserId
- thas it: an ID which is guaranteed to not be equal to the userId
of otherUser
. There's several options for achieving this guarantee (including, as you'll see soon, the ==>
operator), but a simple way is to add a non-zero number to the number you need to avoid.
You then exercise the post
function and, as a verification, call a reusable assertPostFailure
function:
assertPostFailure :: (Eq s, Monad m) => s -> HttpResponse a -> StateT s m Bool assertPostFailure stateBefore resp = do stateAfter <- get let stateDidNotChange = stateBefore == stateAfter return $ stateDidNotChange && isBadRequest resp
This function verifies that the state of the database didn't change, and that the response value represents a 400 Bad Request
HTTP response. This verification doesn't actually verify that the error message associated with the BadRequest
case is the expected message, like in the previous article. This would, however, involve a fairly trivial change to the code.
Similar to the above test case, users will also fail to connect if the 'other user' doesn't exist. The property is almost identical:
testProperty "Users don't connect when other user doesn't exist" $ \ (Positive i) user -> runStateTest $ do let db = Map.fromList [toDBEntry user] put db let uniqueOtherUserId = show $ userId user + i actual <- post lookupUser updateUser (show $ userId user) uniqueOtherUserId assertPostFailure db actual
Since this test body is so similar to the previous test, I'm not going to give you a detailed walkthrough. I did, however, promise to describe the runStateTest
helper function:
runStateTest :: State (Map k a) b -> b runStateTest = flip evalState Map.empty
Since this is a one-liner, you could also write all the tests by simply in-lining that little expression, but I thought that it made the tests more readable to give this function an explicit name.
It takes any State (Map k a) b
and runs it with an empty map. Thus, all State
-valued functions, like the tests, must explicitly put data into the state. This is also what the tests do.
Notice that all the tests return State
values. For example, the assertPostFailure
function returns StateT s m Bool
, of which State s Bool
is an alias. This fits State (Map k a) b
when s
is Map k a
, which again is aliased to DB
. Reducing all of this, the tests are simply functions that return Bool
.
Finally, you can also cover the two test cases where one of the user IDs is invalid:
testProperty "Users don't connect when user Id is invalid" $ \ s otherUser -> isIdInvalid s ==> runStateTest $ do let db = Map.fromList [toDBEntry otherUser] put db actual <- post lookupUser updateUser s (show $ userId otherUser) assertPostFailure db actual , testProperty "Users don't connect when other user Id is invalid" $ \ s user -> isIdInvalid s ==> runStateTest $ do let db = Map.fromList [toDBEntry user] put db actual <- post lookupUser updateUser (show $ userId user) s assertPostFailure db actual
Both of these properties take a String
value s
as input. When QuickCheck generates a String
, that could be any String
value. Both tests require that the value is an invalid user ID. Specifically, it mustn't be possible to parse the string into an Integer
. If you don't constrain QuickCheck, it'll generate various strings, including e.g. "8"
and other strings that can be parsed as numbers.
In the above "Users don't connect when user doesn't exist"
test, you saw how one way to explicitly model constraints on data is to project a seed value in such a way that the constraint always holds. Another way is to use QuickCheck's built-in ==>
operator to filter out undesired values. In this example, both tests employ the isIdInvalid
function:
isIdInvalid :: String -> Bool isIdInvalid s = let userInt = readMaybe s :: Maybe Integer in isNothing userInt
Using isIdInvalid
with the ==>
operator guarantees that s
is an invalid ID.
While state-based testing may, at first, sound incompatible with strictly functional programming, it's not only possible with the State monad, but even, with good language support, easily done.
The tests shown in this article aren't concerned with the interactions between the SUT and its dependencies. Instead, they compare the initial state with the state after exercising the SUT. Comparing values, even complex data structures such as maps, tends to be trivial in functional programming. Immutable values typically have built-in structural equality (in Haskell signified by the automatic Eq
type class), which makes comparing them trivial.
Now that we know that state-based testing is possible even with Haskell's enforced purity, it should be clear that we can repeat the feat in F#.


#include <lwres/lwres.h>
void
lwres_conf_init
(lwres_context_t *ctx);
void
lwres_conf_clear
(lwres_context_t *ctx);
lwres_result_t
lwres_conf_parse
(lwres_context_t *ctx, const char *filename);
lwres_result_t
lwres_conf_print
(lwres_context_t *ctx, FILE *fp);
lwres_conf_t *
lwres_conf_get
(lwres_context_t *ctx);
lwres_conf_init()
creates an empty
lwres_conf_t
structure for lightweight resolver context
ctx.
lwres_conf_clear()
frees up all the internal memory used by
that
lwres_conf_t
structure in resolver context
ctx.
lwres_conf_parse()
opens the file
filename
and parses it to initialise the resolver context
ctx's
lwres_conf_t
structure.
lwres_conf_print()
prints the
lwres_conf_t
structure for resolver context
ctx
to the
FILE
fp.
lwres_conf_parse()
returns
LWRES_R_SUCCESS
if it successfully read and parsed
filename.
It returns
LWRES_R_FAILURE
if
filename
could not be opened or contained incorrect
resolver statements.
lwres_conf_print()
returns
LWRES_R_SUCCESS
unless an error occurred when converting the network addresses to a
numeric host address string.
If this happens, the function returns
LWRES_R_FAILURE.


The subject preference is as follows: Mathematics (everyday) - 1, English - 2, Science - 3, French - 4, History - 5. You need to pick a minimum of 18 hours per week


Name
Count
Count Per Second
Total Bytes
Bytes Per Second
Name
Count
Count Per Second
Total Bytes
Bytes Per Second


Enabling the Erase Service Plug-In
One of the newest restrictions introduced in macOS Mojave now requires explicit permission from the user to use third party Automator actions, which is what Permanent Eraser 2 uses for its Erase service. Upon using the Erase service from a contextual menu in Mojave's Finder, the user will see the following prompt:
- Click on the Open Automator button, which will launch that application.
- Select the Automator > Third Party Automator Actions... menu.
- In the Third Party Automator Actions window which appears, select the Enable Automator actions from third parties checkbox and click the OK button.
You are now set up to use third party Automator actions again. This process only needs to be performed once.


{% extends "layout.html" %} {% block page_title %} How would you like us to contact you? - {{ proto.title }} - GOV.UK {% endblock %} {% block content %} {{ super() }} How would you like us to contact you? How would you like us to contact you? We may need to contact you about your application Mobile number - We can provide text updates quickly via SMS Mobile number Landline number Telephone number Form Navigation {% endblock %} {% block body_end %} {{ super() }} {% endblock %}
We may need to contact you about your application


Last Updated - 11/02/2021
View the 100% Orange Juice full modding guide here.
日本語のMODマニュアルはこちらです。
You can also join our Discord server
where you can
discuss in our modding channel!
Disclaimer:
- I am not a web dev!
- There is no official support for it so do not report bugs in the #support channel!
- I made this quickly to try and help people making mods in the new format
- Feel free to fork and make changes: https://github.com/hexundev/100oj-modgen
Notice
Before making any mod public, it is the responsibility of the creator to refer to the latest version of the
guide linked above to make sure their mod is compatible with the current mod guidelines and use limitations.
Load Mod
In the future you'll be able to load legacy mods.
Mod Definition
Basic Information
Mod replacements
The sections below include various things you can replace.
Your mod can include many kinds of replacements such as textures, music, voices and so on.
You do not need to fill in each section, only the one(s) you want.
Textures
Add a Texture (Basic)
For units you can specify all poses or a single one.
Examples:
units/cuties_00 replaces all poses (cuties_00_00 to cuties_00_05)
units/cuties_00_01 only replaces this pose.
Add a Texture (Advanced)
Music
You can replace character music or music used for events, see the guide for more info.
Character Music
Event Music
Voices
You can replace a character and/or system voice in this section. See the guide for info on what files to
include in your mod.
Character Voice
System Voice
Sound Effects
You can replace a sound effect by adding its file name. You do not need to include .wav.
Character Hair Colors
JSON Output
You can copy the output below or press the "Download" button.
Pressing "Download" will always update the JSON data first.


Home
Movies
Dinner
About
Register
Contact
What's A Movie Without Dinner?
The phrase "dinner and a movie" didn't happen by accident.
Enhance your night at the movies by discussing what might happen over a bite before it starts or while figuring lout how many thumbs you think it deserves after it ends.
Search
Need Cusine Suggestions? Click Here!
Click Here For Restaurants Near You Right Now!
American
Chinese
French
Greek
Indian
Italian
Japanese
Mediterranean
Mexican
Thai


{% extends "bootstrap.html" %} {% set active_page = 'Welcome' %} {% block content %}
Welcome to this dope Movie Selector! Head over to the select page, and after filling out a few preferences we will send you an email with 3 movie recommendations that fit your needs. If you want to know more about us, see About. See you at the movies!
{% endblock %}


A pomeranian in Hong Kong recently made news after testing positive for the novel coronavirus that was first detected in China. The dog's owner had previously tested positive for COVID-19, and concerns quickly mounted that dogs may be a new source of infection....more
BLOG
CAN DOGS GET CORONAVIRUS?
IS IT SAFE TO FLY YOUR PET IN CARGO?
Is the cargo area safe for pet travel? Will dogs too large for in-cabin pet travel be comfortable in the hold of the plane?...more
HOW TO CHOOSE THE BEST DOG FOOD
How do you choose the best dog food for your pup? The endless selection of dog food products with promising marketing claims make the task of selecting dog food incredibly challenging. Do you go with the dog food brand that claims it only uses all-natural ingredients? Is organic better? And what does "all-natural" even mean!?...more


{% block top_of_page %}{% endblock %}
GOV.UK uses cookies to make the site simpler. Find out more about cookies


West Ham poke fun at new Tottenham boss Mourinho ahead of derby clash
West Ham have upped the ante ahead of Jose Mourinho’s first game in charge of Tottenham by goading the Portuguese on Twitter.
Mourinho has taken over from Mauricio Pochettino at Spurs and his reign begins with a derby at the London Stadium on Saturday lunchtime.
And the Hammers were quick to remind Mourinho of his previous failures against them by posting a video on the social media site along with the caption “See you Saturday, Jose”.
The video included a previous quote from Mourinho about West Ham’s style of play and then footage of Manchester United’s defeat in east London last season.
The baiting adds another sub-plot to an already intriguing battle on Saturday.
All eyes will be on how Spurs line-up under Mourinho, but the pressure is also firmly on Manuel Pellegrini following a run of five defeats and two draws from their last seven games.
READ MORE
Mourinho meets Spurs squad as new manager gears up for first game


Home
About
Powered by
Jekyll
© 2015. All rights reserved.
Raja
Version 0.1
Popup Dictionary
16 Nov 2015
Zeroth post
14 Nov 2015
What's Jekyll?
31 Dec 2013
Older
Newer


 I took 1Tbsp right out. waited about 10min and noticed interesting effects.
i was using the Erowid Ghb dosage page for dosing information and decided that, since i weigh ~140kg (yep, im an ogre), that perhaps the 'larger person' dose applied to me. I decided that 3g would probably be an appropriate dose and, hey, i can 'hold my liquor,' as it were, with drugs.
I promptly took 2 more tablespoons.
effects started coming on and I watched some sally field/keifer sutherland moving on tv. i noticed some stomach upset, and went to go get some food, knowing i hadnt eaten in about 8 hours.
i started eating but couldnt bring myself to eat much, and decided i wasnt really hungry. i had been confined to the couch for the last 30min by choice, mostly, because i wasnt sure of the motor skills i would have, as effects were strong. i got up, and it was not walking, really, but more a semi-controlled pointing method, where i would point my body, and my legs would push me around. it was very awkward.
for some reason intense sexual urges welled up. im not sure... it was rather interesting, actually, how it sort of welled up in me, and came on rather suddenly (please excuse any puns i make make). sex was verrrrrrry interesting. 'stamina' was not increased, per se, but feelings were incredible. it was if i could just stop escalating, and maintain a sexual tension level until i was comfortable proceeding, while still being stimulating.
definitely worth a few more 'experiments.'
then the vomit happened. i had sort of spat up as an infant would, my crackers from earlier, before sex. but this was real vomiting. this was unpleasant. all the food in my stomach went into a cup that i was holding to my mouth as i retched uncontrollably for what seemed like 10 or 15 minutes and was really, only in fact about 3. the vomiting ceased, but the food was gone, and the heaves began again.
im not normally a 'vomiter,' and only dxm has made me vomit in recent history (recent being the last decade). after the vomiting ceased again, i began to calm myself down. i think the vomiting was caused by the fact i was thinking about it. i wasnt nauseated when i was watching tv because i wasnt concentrating on my stomach. i turned some music on, and liked it. i turned it up, and the sick smell of bile/digestive stuff/vomit wafted out the window, which was wide open.
i curled up on the bed and listened to the music. i found a shirt that smelled like my mate, and held it up close to my face so that i could smell her, and further relax with the music. i very quickly fell asleep. i dont know if it was that 'unrousable' sleep common of ghb use, but i doubt it. i dont remember dreaming, but i woke up fine about 5hrs later when the phone rang.
now, for those of you who are about to reply and chastise my kitchen chemistry, yes, i realize the mistake. according to my calculator, 1 Tbsp = 14.787ml. so, providing i took 3T, thats 3x14.787ml, or 44.360ml. Now, divide this by 5, thats 8.872g. So, 140kg/8.872g = 63mg/kg.
according to the above mentioned page (at erowid), and providing your average human weighs 160lb (73kg), 63mg/kg would equal 4.599g, or 'can induce heavy sleep.'
I would say that that is not true. I only fell asleep after I was done vomiting. :) so maybe the page should be changed to 'Can induce heavy vomiting, increased sexual stimulation, and possibly sleep. Avoid salty crackers.' :)
The overall 'trip' lasted about 1.5-2hrs.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.