Skip to content

Commit

Permalink
Merge pull request #16 from MushroomObserver/ror4
Browse files Browse the repository at this point in the history
Ror4
  • Loading branch information
raysuelzer committed Feb 7, 2015
2 parents 06b0427 + dcce8d0 commit c17bafb
Show file tree
Hide file tree
Showing 54 changed files with 456 additions and 226 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# See https://help.github.com/articles/ignoring-files
# for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# OS generated files #
######################
.DS_Store
Expand All @@ -10,12 +17,14 @@ ehthumbs.db
Thumbs.db
*~

# Ignore all logfiles and tempfiles.
tmp/
log/
checkpoints/
production-logs
.tm_properties

# Ignore bundler config.
.bundle
.rubocop_todo.yml
rubocop.out
Expand Down
12 changes: 6 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ gem "mysql2"
# gem "sqlite3"

# Use SCSS for stylesheets
gem "sass-rails", "~> 4.0"
gem "sass-rails"

# Use jquery as the JavaScript library
gem "jquery-rails"
Expand All @@ -20,10 +20,10 @@ gem "jquery-rails"
gem "therubyracer", platforms: :ruby

# Use CoffeeScript for .js.coffee assets and views
gem "coffee-rails", "~> 4.0"
gem "coffee-rails"

# Use Uglifier as compressor for JavaScript assets
gem "uglifier", ">= 1.0.3"
gem "uglifier"

# Turbolinks makes following links in your web application faster.
# Read more: https://github.com/rails/turbolinks
Expand Down Expand Up @@ -81,6 +81,6 @@ gem "coveralls", require: false
# Use rubocop for code style quality control
gem "rubocop", require: false




# Brakeman static analysis security scanner
# See http://brakemanscanner.org/
gem "brakeman", require: false
45 changes: 34 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ GEM
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
blankslate (3.1.3)
brakeman (3.0.1)
erubis (~> 2.6)
fastercsv (~> 1.5)
haml (>= 3.0, < 5.0)
highline (~> 1.6.20)
multi_json (~> 1.2)
ruby2ruby (~> 2.1.1)
ruby_parser (~> 3.5.0)
sass (~> 3.0)
terminal-table (~> 1.4)
browser (0.8.0)
builder (3.1.4)
byebug (3.5.1)
Expand All @@ -43,9 +53,9 @@ GEM
coffee-script (2.3.0)
coffee-script-source
execjs
coffee-script-source (1.8.0)
coffee-script-source (1.9.0)
columnize (0.9.0)
coveralls (0.7.3)
coveralls (0.7.8)
multi_json (~> 1.10)
rest-client (~> 1.7)
simplecov (~> 0.9.1)
Expand All @@ -58,6 +68,10 @@ GEM
erubis (2.7.0)
execjs (2.2.2)
fakeweb (1.3.0)
fastercsv (1.5.5)
haml (4.0.6)
tilt
highline (1.6.21)
hike (1.2.3)
i18n (0.7.0)
jquery-rails (3.1.2)
Expand Down Expand Up @@ -107,12 +121,19 @@ GEM
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.7.1)
sass (3.2.19)
sass-rails (4.0.5)
ruby2ruby (2.1.3)
ruby_parser (~> 3.1)
sexp_processor (~> 4.0)
ruby_parser (3.5.0)
sexp_processor (~> 4.1)
sass (3.4.11)
sass-rails (5.0.1)
railties (>= 4.0.0, < 5.0)
sass (~> 3.2.2)
sprockets (~> 2.8, < 3.0)
sprockets-rails (~> 2.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (~> 1.1)
sexp_processor (4.4.5)
simple_enum (2.1.1)
activesupport (>= 4.0.0)
simplecov (0.9.1)
Expand All @@ -132,14 +153,15 @@ GEM
sprockets (>= 2.8, < 4.0)
term-ansicolor (1.3.0)
tins (~> 1.0)
terminal-table (1.4.5)
therubyracer (0.12.1)
libv8 (~> 3.16.14.0)
ref
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
tins (1.3.3)
tzinfo (0.3.42)
tzinfo (0.3.43)
uglifier (2.7.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
Expand All @@ -154,9 +176,10 @@ PLATFORMS
DEPENDENCIES
RedCloth
blankslate
brakeman
browser
byebug
coffee-rails (~> 4.0)
coffee-rails
coveralls
cure_acts_as_versioned
fakeweb (~> 1.3)
Expand All @@ -166,8 +189,8 @@ DEPENDENCIES
rails (~> 4.0.0)
rtf
rubocop
sass-rails (~> 4.0)
sass-rails
simple_enum
therubyracer
uglifier (>= 1.0.3)
uglifier
unicorn
5 changes: 3 additions & 2 deletions README_PRODUCTION_INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ mo> git clone https://github.com/MushroomObserver/mushroom-observer .
[NJW: Remember to switch to another branch if you are testing this process
on code not on the master branch.]

mo> mkdir log log/old tmp public/images/{thumb,320,640,960,1280,orig}
mo> mkdir log log/old tmp tmp/pids tmp/sockets
mo> mkdir public/images/{thumb,320,640,960,1280,orig}
mo> ln -s images public/local_images
mo> cp config/etc/bash_aliases.sh ~/.bash_aliases
mo> vi config/consts-site.rb
Expand Down Expand Up @@ -254,7 +255,7 @@ root> vi /etc/logrotate.d/unicorn
delaycompress
sharedscripts
postrotate
kill -HUP `cat /var/web/mushroom-observer/tmp/unicorn.pid`
kill -HUP `cat /var/web/mushroom-observer/tmp/pids/unicorn.pid`
mv /var/web/mushroom-observer/log/*.gz /var/web/mushroom-observer/log/old/
endscript
}
Expand Down
9 changes: 4 additions & 5 deletions app/controllers/account_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ def login # :nologin: :prefetch:
@login = ""
@remember = true
else
@login = params["user_login"].to_s
@password = params["user_password"].to_s
@remember = params["user"] && params["user"]["remember_me"] == "1"
@login = params[:user][:login].to_s rescue ""
@password = params[:user][:password].to_s rescue ""
@remember = params[:user][:remember_me] == "1" rescue false
user = User.authenticate(@login, @password)
user ||= User.authenticate(@login, @password.strip)
if !user
Expand All @@ -231,8 +231,7 @@ def login # :nologin: :prefetch:
@unverified_user = user
render(action: "reverify")
else
logger.warn("%s, %s, %s" % [user.login, params["user_login"],
params["user_password"]])
# logger.warn("%s, %s, %s" % [user.login, @login, @password]])
flash_notice :runtime_login_success.t
@user = user
@user.last_login = now = Time.now
Expand Down
50 changes: 33 additions & 17 deletions app/controllers/species_list_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def create_species_list # :prefetch: :norobots:
end
@checklist ||= calc_checklist
else
process_species_list("created_at")
process_species_list(:create)
end
end

Expand All @@ -353,7 +353,7 @@ def edit_species_list # :prefetch: :norobots:
init_project_vars_for_edit(@species_list)
@checklist ||= calc_checklist
else
process_species_list("updated")
process_species_list(:update)
end
end
end
Expand Down Expand Up @@ -672,13 +672,13 @@ def remove_images_from_project(proj)
# val: id of name user has chosen (via radio boxes in feedback)
# params[:checklist_data][...] Radio boxes on left side: hash from name id to "1".
# params[:checklist_names][name_id] (Used by view to give a name to each id in checklist_data hash.)
def process_species_list(created_or_updated)
def process_species_list(create_or_update)
redirected = false
args = params[:species_list]

# Update the timestamps/user/when/where/title/notes fields.
now = Time.now
@species_list.created_at = now if created_or_updated == :created_at
@species_list.created_at = now if create_or_update == :create
@species_list.updated_at = now
@species_list.user = @user
@species_list.attributes = args.permit(whitelisted_species_list_args) if args
Expand Down Expand Up @@ -746,15 +746,16 @@ def process_species_list(created_or_updated)
if !@species_list.save
flash_object_errors(@species_list)
else
@species_list.log("log_species_list_#{created_or_updated}".to_sym)
if created_or_updated == :created_at
if create_or_update == :create
@species_list.log(:log_species_list_created_at)
flash_notice(:runtime_species_list_create_success.t(id: @species_list.id))
else
@species_list.log(:log_species_list_updated)
flash_notice(:runtime_species_list_edit_success.t(id: @species_list.id))
end

update_projects(@species_list, params[:project])
construct_observations(@species_list, sorter, created_or_updated)
construct_observations(@species_list, sorter)

if @species_list.location.nil?
redirect_to(controller: "location", action: "create_location",
Expand All @@ -780,7 +781,7 @@ def process_species_list(created_or_updated)
# Uses the member instance vars, as well as:
# params[:chosen_approved_names] Names from radio boxes.
# params[:checklist_data] Names from LHS check boxes.
def construct_observations(spl, sorter, created_or_updated)
def construct_observations(spl, sorter)

# Put together a list of arguments to use when creating new observations.
member_args = params[:member] || {}
Expand Down Expand Up @@ -942,19 +943,34 @@ def init_member_vars_for_create()
end

def init_member_vars_for_edit(spl)
if obs = @species_list.observations.last
init_member_vars_for_create()
if obs = spl.observations.last
# TODO: Not sure how to check vote efficiently...
@member_vote = obs.namings.first.users_vote(@user).value rescue Vote.maximum_vote
@member_notes = obs.notes
@member_lat = obs.lat
@member_long = obs.long
@member_alt = obs.alt
@member_is_collection_location = obs.is_collection_location
@member_specimen = obs.specimen
else
init_member_vars_for_create()
if all_obs_same?(spl, obs, :notes)
@member_notes = obs.notes
end
if all_obs_same?(spl, obs, :lat, :long, :alt)
@member_lat = obs.lat
@member_long = obs.long
@member_alt = obs.alt
end
if all_obs_same?(spl, obs, :is_collection_location)
@member_is_collection_location = obs.is_collection_location
end
if all_obs_same?(spl, obs, :specimen)
@member_specimen = obs.specimen
end
end
end

# Do all observations in spl have same values for the given attributes?
def all_obs_same?(spl, obs, *attrs)
cond = attrs.map {|a| "observations.#{a} != ?"}.join(" OR ")
vals = attrs.map {|a| obs.send(a)}
spl.observations.where(cond, *vals).limit(1).count == 0
end

def init_member_vars_for_reload()
@member_vote = params[:member][:vote].to_s rescue ""
@member_notes = params[:member][:notes].to_s rescue ""
Expand Down
6 changes: 0 additions & 6 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1002,12 +1002,6 @@ def injected_javascripts
@javascript_codes || []
end

# Insert a javacsript snippet that causes the browser to focus on a given
# input field when it loads the page.
def focus_on(id)
inject_javascript_at_end("document.getElementById('#{id}').focus()")
end

# Hide an element right away, don't wait to inject at end, because it makes
# the browser window jump around erratically as it's loading.
def hide_element(id)
Expand Down
11 changes: 6 additions & 5 deletions app/views/account/choose_password.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<% @title = :account_choose_password_title.t %>
<%
@title = :account_choose_password_title.t
focus_on_password = @user.password.blank?
%>

<%= form_tag(:action=> "verify", :id => @user.id, :auth_code => @user.auth_code) do %>
<label for="user_password"><%= :signup_choose_password.t %>:</label><br/>
<%= password_field "user", "password", :size => 30, :value => @user.password %><br/><br/>
<%= password_field(:user, :password, size: 30, value: @user.password, autofocus: focus_on_password) %><br/><br/>

<label for="user_password_confirmation"><%= :signup_confirm_password.t %>:</label><br/>
<%= password_field "user", "password_confirmation", :size => 30 %><br/><br/>
<%= password_field(:user, :password_confirmation, size: 30, autofocus: !focus_on_password) %><br/><br/>

<input type="submit" value="<%= :SUBMIT.l %>" class="primary" />

<% focus_on(@user.password.blank? ? 'user_password' : 'user_password_confirmation') %>
<% end %>
5 changes: 1 addition & 4 deletions app/views/account/email_new_password.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<% @title = :email_new_password_title.t %>

<%= form_tag(:action => "email_new_password") do %>

<label for="new_user_login"><%= :login_user.t %>:</label><br/>
<%= text_field "new_user", "login", :size => 30 %><br/><br/>
<%= text_field(:new_user, :login, size: 30, autofocus: true) %><br/><br/>

<input type="submit" value="<%= :SEND.l %>" class="primary" />

<% focus_on('new_user_login') %>
<% end %>
8 changes: 3 additions & 5 deletions app/views/account/login.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<%= form_tag(:action => "login") do %>

<label for="user_login"><%= :login_user.t %>:</label><br/>
<input type="text" name="user_login" id="user_login" size="30" value="<%= @login %>"/><br/><br/>
<%= text_field(:user, :login, size: 30, value: @login, autofocus: @login.blank?) %><br/><br/>

<label for="user_password"><%= :login_password.t %>:</label><br/>
<input type="password" name="user_password" id="user_password" size="30"/><br/><br/>
<%= password_field(:user, :password, size: 30, value: "", autofocus: !@login.blank?) %><br/><br/>

<%= check_box('user', 'remember_me', :checked => @remember) %>
<%= check_box(:user, :remember_me, checked: @remember) %>
<label for="user_remember_me"><%= :login_remember_me.t %></label><br/><br/>

<input type="submit" name="login" value="<%= :login_login.l %>" class="primary" />
Expand All @@ -17,6 +17,4 @@
<%= :login_forgot_password.tp %>
<%= :login_no_account.tp %>
<%= :login_having_problems.tp %>

<% focus_on(!@login.blank? ? 'user_password' : 'user_login') %>
<% end %>
4 changes: 1 addition & 3 deletions app/views/account/signup.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= form_tag(:action=> "signup") do %>

<label for="new_user_login"><%= :signup_login.t %>:</label><br/>
<%= text_field "new_user", "login", :size => 30 %><br/><br/>
<%= text_field(:new_user, :login, size: 30, autofocus: true) %><br/><br/>

<label for="new_user_password"><%= :signup_choose_password.t %>:</label><br/>
<%= password_field "new_user", "password", :size => 30, :value => @new_user.password %><br/><br/>
Expand All @@ -23,6 +23,4 @@

<input type="submit" value="<%= :signup_button.l %>" class="primary" />

<% focus_on('new_user_login') %>

<% end %>
Loading

0 comments on commit c17bafb

Please sign in to comment.