Skip to content

Commit

Permalink
Merge pull request #13 from datacommons/readonly
Browse files Browse the repository at this point in the history
land readonly stonesoup site
  • Loading branch information
paulfitz authored May 8, 2018
2 parents 134870c + 1ccdfcc commit a3b53d4
Show file tree
Hide file tree
Showing 223 changed files with 1,072 additions and 9,668 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ source "https://rubygems.org"

ruby '1.8.7'

ruby '1.8.7'

gem "oj", "~> 2.2.0"
gem "rack", "~> 1.1.0"
gem "geokit", "~> 1.6.7"
gem "google-v3-geocoder", "~> 1.0.0"
gem "ferret", "~> 0.11.8.5"
gem "json", "~> 1.8.1"
gem "mysql", "~> 2.9.1"
gem "fastercsv", "~> 1.5.5"
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ GEM
remote: https://rubygems.org/
specs:
fastercsv (1.5.5)
ferret (0.11.8.5)
geokit (1.6.7)
multi_json (>= 1.3.2)
google-v3-geocoder (1.0.0)
Expand All @@ -11,6 +10,7 @@ GEM
json (1.8.1)
multi_json (1.10.1)
mysql (2.9.1)
oj (2.2.3)
rack (1.1.6)
rake (0.9.2.2)
sqlite3 (1.3.11)
Expand All @@ -20,11 +20,11 @@ PLATFORMS

DEPENDENCIES
fastercsv (~> 1.5.5)
ferret (~> 0.11.8.5)
geokit (~> 1.6.7)
google-v3-geocoder (~> 1.0.0)
json (~> 1.8.1)
mysql (~> 2.9.1)
oj (~> 2.2.0)
rack (~> 1.1.0)
rake (~> 0.9.2.2)
sqlite3
Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,3 @@ You can then run the development server as:
```
$ ./script/server
```

To enable search indexing, do:
```
$ ruby ./script/ferret_server -e development -R `pwd` start
```
27 changes: 26 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,32 @@ def render_entries
format.csv do
data = [@entries].flatten
data = data.map {|r| r.reportable_data}.flatten
cols = Organization.column_names
data.each do |d|
if (!d['mailing_state'].blank?) and d['physical_state'].blank?
d['physical_city'] = d['mailing_city']
d['physical_state'] = d['mailing_state']
d['physical_country'] = d['mailing_country']
end
end
cols = [
'name',
'phone',
'website',
'email',
'fax',
'physical_address1',
'physical_address2',
'physical_city',
'physical_state',
'physical_zip',
'physical_country',
'description',
'tag_names',
'founded',
'latitude',
'longitude',
'dso'
]
table = Ruport::Data::Table.new(:data => data,
:column_names => cols)
send_data table.to_csv,
Expand Down
1 change: 0 additions & 1 deletion app/controllers/data_sharing_orgs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ def link_taggable
if(DataSharingOrgsTaggable.set_status(dso, org, params[:verified] || false))
status = (params[:verified] ? 'verified' : 'unverified')
flash[:notice] = "#{org.name} was successfully added to the data pool for #{dso.name} as #{status}"
org.ferret_update
else
flash[:error] = "Couldn't add Org to DSO"
end
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def create
merge_check
@location = @organization.locations.create(params[:location])
@location.save!
@organization.ferret_update
flash[:notice] = 'Location was successfully created.'
respond_to do |format|
format.html { redirect_to(@location) }
Expand All @@ -84,7 +83,6 @@ def update

respond_to do |format|
if @location.update_attributes(params[:location])
@organization.ferret_update
flash[:notice] = 'Location was successfully updated.'
format.html { redirect_to(@location) }
format.xml { head :ok }
Expand All @@ -106,7 +104,6 @@ def move
if @organization2.primary_location == @location
@organization2.update_attribute(:primary_location, nil)
end
@organization.ferret_update
flash[:notice] = 'Location was successfully updated.'
respond_to do |format|
format.html { redirect_to(@location) }
Expand All @@ -122,7 +119,6 @@ def destroy
@organization = @location.taggable
merge_check
@location.destroy
@organization.ferret_update

respond_to do |format|
format.html { redirect_to(locations_url) }
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/org_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def dissociate
@organization.org_types.delete(@org_type)
@organization.save!
@organization.notify_related_record_change(:deleted, @org_type)
@organization.ferret_update
render :partial => 'manage'
end

Expand All @@ -20,7 +19,6 @@ def associate
@organization.org_types.push(@org_type)
@organization.save!
@organization.notify_related_record_change(:added, @org_type)
@organization.ferret_update
render :partial => 'manage'
end

Expand Down
18 changes: 18 additions & 0 deletions app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ def show
redirect_to :controller => 'search' and return
end

@peers = []
if @organization.grouping
@peers = Organization.find_all_by_grouping(@organization.grouping).select{
|x| x.id != @organization.id
}
past = DateTime.now - 10000.years
@peers = @peers.sort_by { |x| x.updated_at || past }
@peers.reverse!
end
@orgs = [@organization] + @peers

@all_verified_dsos = @orgs.map{|x| x.verified_dsos}.flatten.compact.uniq

# following is not actually a DataSharingOrg (*shame*)
@source_info = DataSharingOrg.find_by_sql(["select * from sources where sources.key in (?)", @all_verified_dsos.map{|x| x.key}])

@sponsor_info = @source_info.map{|x| Organization.get_sponsors(x)}.flatten.uniq

#if not(@organization.latitude)
# @organization.save_ll
# @organization.save
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/plumbing_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ def index
def org
@orgs = Organization.find(:all)
@orgs.each do |org|
org.ferret_update
# do not need to do anything anymore
end
end

def ppl
@data = Person.find(:all)
@data.each do |datum|
datum.ferret_update
# do not need to do anything anymore
end
end

Expand Down
25 changes: 22 additions & 3 deletions app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ class SearchController < ApplicationController

# before_filter :login_required, :only => [:inspect]

before_filter(:only => [:search, :map, :near]) do |controller|
controller.send(:login_required) if ['json', 'kml', 'pdf', 'csv', 'yaml', 'xml'].include? controller.request.format
end

public

def index
Expand All @@ -10,13 +14,16 @@ def index
render :action => 'search'
else
@welcome_page = true
@source_info = DataSharingOrg.find_by_sql(["select * from sources order by name"])
render :action => 'welcome'
end
end

def test
_params = {}
@entries, @counts = @template.search_core(_params,@site,{ :unlimited_search => true }, true)
@entries, @counts, @counts_dsos = @template.search_core(_params,@site,{
:unlimited_search => true
}, true)
@entries.reject!{|e| e.kind_of? Person}
@entries.uniq!
@entries.sort!{|a,b| a.oname <=> b.oname}
Expand All @@ -38,7 +45,7 @@ def search
# _params[:q] = search_query
#end

@entries, @counts = @template.search_core(_params,@site,{ :unlimited_search => @unlimited_search, :params => _params }, true)
@entries, @counts, @counts_dsos = @template.search_core(_params,@site,{ :unlimited_search => @unlimited_search, :params => _params }, true)

if params[:merge]
@merge_active = true
Expand All @@ -52,13 +59,17 @@ def search
end
@merge_target = session[:merge]

if @unlimited_search
@map_style = true
end
if params[:q]
render_entries
end
end

def map
@unlimited_search = true
@map_style = true
search
end

Expand Down Expand Up @@ -140,6 +151,14 @@ def mini_map
render :partial => "search/map"
end

def mini_map2
@name = params[:name]
@link = YAML::load(params[:link])
@orgs = @template.get_listing_for_link(@name,@link,@site.name)
@rendered = true
render :partial => "search/map2"
end

def change_filter
if params[:name]
key = ("active_" + params[:name] + "_filter").to_sym
Expand Down Expand Up @@ -377,7 +396,7 @@ def auto_complete
condParams << value
conditions = []
conditions = [condSQLs.collect{|c| "(#{c})"}.join(' AND ')] + condParams unless condSQLs.empty?
organizations = Organization.find(:all, :conditions => conditions, :joins => joinSQL, :limit => limit*5)
organizations = Organization.find(:all, :conditions => conditions, :joins => joinSQL, :limit => limit*5, :group => 'coalesce(grouping, organizations.id)')
end

if name.length>=2
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/sectors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def dissociate
@organization.sectors.delete(@sector)
@organization.save!
@organization.notify_related_record_change(:deleted, @sector)
@organization.ferret_update
render :partial => 'manage'
end

Expand All @@ -20,7 +19,6 @@ def associate
@organization.sectors.push(@sector)
@organization.save!
@organization.notify_related_record_change(:added, @sector)
@organization.ferret_update
render :partial => 'manage'
end

Expand Down
2 changes: 0 additions & 2 deletions app/controllers/tags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def dissociate
@taggable.taggings.delete(@tagging)
@taggable.save!
# @taggable.notify_related_record_change(:deleted, @tag)
@taggable.ferret_update
@organization = @taggable
render :partial => 'manage'
end
Expand All @@ -54,7 +53,6 @@ def associate
@organization.tags.push(@tag)
@organization.save!
# @organization.notify_related_record_change(:added, @tag)
@organization.ferret_update
render :partial => 'manage'
end

Expand Down
39 changes: 37 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class UsersController < ApplicationController
before_filter :login_required, :only => [:new, :create, :edit, :update, :destroy, :index, :list, :show, :prefs, :update_prefs]
before_filter :login_required, :only => [:new, :create, :edit, :update, :destroy, :index, :list, :show, :prefs, :update_prefs, :old_signup]
before_filter :admin_required, :only => [:index, :list, :new, :create, :edit, :update, :destroy]

def index
Expand Down Expand Up @@ -45,8 +45,43 @@ def login
end
end
end

def old_login
case request.method
when :post
if params[:login] # attempting a login
if session[:user] = User.authenticate(params['user_login'], params['user_password'])

session[:user].update_attribute('last_login', DateTime.now)
flash['notice'] = "Login successful"
redirect_back_or_default :controller => 'search', :action => "index"
else
@login = params['user_login']
@message = "Login unsuccessful"
end
elsif params[:forgot_pass] # requesting password reset
if params[:user_login].blank?
@login = params['user_login']
@message = "Enter your e-mail address to reset your password."
else
user = User.find_by_login(params[:user_login])
if user.nil?
@login = params['user_login']
@message = "No user was found with for that e-mail address."
else
# reset password and send e-mail
newpass = Common::random_password(user.login)
user.password_cleartext = newpass
user.save!
Email.deliver_password_reset(user, newpass)
@message = "A new password was e-mailed to #{user.login} (if you don't see it, check your spam folder, or whitelist \"find.coop\")"
end
end
end
end
end

def signup
def old_signup
case request.method
when :post
@user = User.new(params['user'])
Expand Down
Loading

0 comments on commit a3b53d4

Please sign in to comment.