Skip to content

Commit

Permalink
Merge branch 'master' into images
Browse files Browse the repository at this point in the history
  • Loading branch information
BethFrank committed Mar 28, 2014
2 parents 95c99c9 + 78aa1e9 commit 23e10e8
Show file tree
Hide file tree
Showing 112 changed files with 1,822 additions and 791 deletions.
3 changes: 2 additions & 1 deletion Gemfile
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
ruby '2.1.1'

gem 'rails', '4.0.3'
gem 'rails', '4.0.4'

# PostgreSQL
gem 'pg', '~> 0.17.0'
Expand Down Expand Up @@ -84,6 +84,7 @@ end
group :test do
gem "rspec"
gem 'coveralls', '~> 0.7', require: false
gem 'capybara', '~> 2.1'
end

group :development do
Expand Down
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -14,15 +14,15 @@ TaxonWorks is Ruby on Rails application that facilitates biodiversity informatic
Installation
------------

TaxonWorks is a Rails 4 application using Ruby 2.0 and rubygems. It requires PostgreSQL with the postgis extension. The core development team is using [rvm][16] and [brew][9] to configure their environment on OS X.
TaxonWorks is a Rails 4 application using Ruby 2.0 and rubygems. It requires PostgreSQL with the postgis extension. It uses ImageMagick. The core development team is using [rvm][16] and [brew][9] to configure their environment on OS X.

Minimally, the following steps are required. If you have postgres installed skip to 3.

1. Install Postgres and postgis.
1. Install Postgres and postgis and image magick.

```
brew install postgres
brew install postgis
brew install postgis
brew install imagemagick
```

Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/sessions.js.coffee
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/users.js.coffee
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/sessions.css.scss
@@ -0,0 +1,3 @@
// Place all the styles related to the sessions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/users.css.scss
@@ -0,0 +1,3 @@
// Place all the styles related to the users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
26 changes: 26 additions & 0 deletions app/controllers/application_controller.rb
Expand Up @@ -2,4 +2,30 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception

layout 'basic'

include SessionsHelper

attr_writer :meta_title, :meta_data, :site_name
attr_accessor :meta_description, :meta_keywords, :page_title

helper_method :meta_title, :meta_data, :site_name, :page_title

def meta_title
@meta_title ||= [@meta_title.presence || @page_title.presence, site_name].
compact.join(' | ')
end

def meta_data
@meta_data ||= {
description: @meta_description,
keywords: @meta_keywords
}.delete_if{ |k, v| v.nil? }
end

def site_name
@site_name ||= 'TaxonWorks'
end

end
3 changes: 3 additions & 0 deletions app/controllers/dashboard_controller.rb
@@ -1,6 +1,9 @@
class DashboardController < ApplicationController

# GET '/'
def index
redirect_to signin_path, status: 301 and return unless sessions_signed_in?
@page_title = 'Your dashboard'
end

end
28 changes: 28 additions & 0 deletions app/controllers/sessions_controller.rb
@@ -0,0 +1,28 @@
class SessionsController < ApplicationController

# GET /signin
def new
@page_title = 'Sign in'
@user = User.new
end

# POST /sessions
def create
user = User.find_by(email: params[:session][:email].downcase)
if user && user.authenticate(params[:session][:password])
sessions_sign_in user
redirect_to root_path
else
@page_title = 'Sign in'
flash.now[:error] = 'Unrecognised email and password combination.'
render 'new'
end
end

# DELETE /signout
def destroy
sessions_sign_out
redirect_to root_url
end

end
68 changes: 68 additions & 0 deletions app/controllers/users_controller.rb
@@ -0,0 +1,68 @@
class UsersController < ApplicationController

# GET /users
def index
@users = User.all
@page_title = 'Users'
end

# GET /signup
def new
@user = User.new
@page_title = 'Create account'
end

# GET /users/:id
def show
@user = User.find(params[:id])
@page_title = "User #{@user.id}"
end

# GET /users/:id/edit
def edit
@user = User.find(params[:id])
@page_title = "Edit user #{@user.id}"
end

# POST /users
def create
@user = User.new(user_params)
if @user.save
sessions_sign_in @user
flash[:success] = 'Thanks for signing up and welcome to TaxonWorks!'
redirect_to root_path
else
@page_title = 'Create account'
render 'new'
end
end

# PATCH or PUT /users/:id
def update
@user = User.find(params[:id])
if @user.update_attributes(user_params)
flash[:success] = 'Changes to your account information have been saved.'
redirect_to @user
else
@page_title = "Edit user #{@user.id}"
render 'edit'
end
end

# DELETE /users/:id
def destroy
User.find(params[:id]).destroy
flash[:success] = "Your account has been deleted."
redirect_to root_url
end

private

def user_params
params.require(:user).permit(:name,
:email,
:password,
:password_confirmation)
end

end
28 changes: 28 additions & 0 deletions app/helpers/sessions_helper.rb
@@ -0,0 +1,28 @@
module SessionsHelper

def sessions_signed_in?
!sessions_current_user.nil?
end

def sessions_current_user=(user)
@sessions_current_user = user
end

def sessions_current_user
remember_token = User.encrypt(cookies[:remember_token])
@sessions_current_user ||= User.find_by(remember_token: remember_token)
end

def sessions_sign_in(user)
remember_token = User.secure_random_token
cookies.permanent[:remember_token] = remember_token
user.update_attribute(:remember_token, User.encrypt(remember_token))
self.sessions_current_user = user
end

def sessions_sign_out
self.sessions_current_user = nil
cookies.delete(:remember_token)
end

end
2 changes: 2 additions & 0 deletions app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
module UsersHelper
end
7 changes: 3 additions & 4 deletions app/models/collection_object/biological_collection_object.rb
@@ -1,10 +1,9 @@
class CollectionObject::BiologicalCollectionObject < CollectionObject
has_many :biocuration_classes, through: :biocuration_classifications
has_many :biocuration_classifications
has_many :otus, through: :taxon_determinations
has_many :taxon_determinations

has_many :biocuration_classifications
has_many :biocuration_classes, through: :biocuration_classifications


accepts_nested_attributes_for :biocuration_classes, :biocuration_classifications, :taxon_determinations, :otus

def current_determination
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/shared/data_attributes.rb
Expand Up @@ -11,7 +11,7 @@ def has_data_attributes?
end

def keyword_value_hash
self.data_attributes.inject({}) do |hsh, a|
self.data_attributes.inject({}) do |hsh, a|
if a.class == ImportAttribute
hsh.merge!(a.import_predicate => a.value)
else # there are only two
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/shared/identifiable.rb
Expand Up @@ -3,6 +3,7 @@ module Shared::Identifiable
included do

has_many :identifiers, as: :identified_object, validate: false
accepts_nested_attributes_for :identifiers

#scope :creator_missing_first_name, -> { where(people: {first_name: nil}).joins(:creator)}
#scope :created_by, lambda {|person| where("created_by_id = ?", person) }
Expand Down

0 comments on commit 23e10e8

Please sign in to comment.