diff --git a/app/assets/stylesheets/admin.css.less b/app/assets/stylesheets/admin.css.less
index 48be624..05664c9 100644
--- a/app/assets/stylesheets/admin.css.less
+++ b/app/assets/stylesheets/admin.css.less
@@ -1164,6 +1164,9 @@
padding:0 2px 10px 0;
}
+td.organisation-logo {
+ padding: 0 25px 10px 25px;
+}
table.dmp_details_table {
margin: 0 0 0 0;
diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb
index 7caca1c..a9ee7a4 100644
--- a/app/controllers/organisations_controller.rb
+++ b/app/controllers/organisations_controller.rb
@@ -58,7 +58,6 @@
def admin_edit
if user_signed_in? && current_user.is_org_admin? then
@organisation = Organisation.find(params[:id])
-
else
render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
end
@@ -69,19 +68,20 @@
# PUT /organisations/1.json
def admin_update
if user_signed_in? && current_user.is_org_admin? then
- @organisation = Organisation.find(params[:id])
- @organisation.banner_text = params["org_banner_text"]
- @organisation.logo = params[:organisation][:logo] if params[:organisation][:logo]
- assign_params = params[:organisation].dup
- assign_params.delete(:logo)
+ @organisation = Organisation.find(params[:id])
+ @organisation.banner_text = params["org_banner_text"]
+ @organisation.logo = params[:organisation][:logo] if params[:organisation][:logo]
+ assign_params = params[:organisation].dup
+ assign_params.delete(:logo)
respond_to do |format|
if @organisation.update_attributes(assign_params)
format.html { redirect_to admin_show_organisation_path(params[:id]), notice: I18n.t("admin.org_updated_message") }
format.json { head :no_content }
else
- flash[:alert] = I18n.t("org_admin.org_logo_failed_message")
- format.html { render action: "admin_edit" }
+ flash[:alert] = @organisation.errors.full_messages.join("
").html_safe if @organisation.errors.any?
+
+ format.html { render action: "admin_edit" }
format.json { render json: @organisation.errors, status: :unprocessable_entity }
end
end
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
index eaed3ba..caccda5 100644
--- a/app/models/organisation.rb
+++ b/app/models/organisation.rb
@@ -1,6 +1,8 @@
+#require 'validators/email_validator'
+
class Organisation < ActiveRecord::Base
include GlobalHelpers
-
+
extend Dragonfly::Model::Validations
#associations between tables
@@ -21,17 +23,21 @@
has_many :children, :class_name => 'Organisation', :foreign_key => 'parent_id'
-# accepts_nested_attributes_for :organisation_type
accepts_nested_attributes_for :dmptemplates
accepts_nested_attributes_for :token_permission_types
- attr_accessible :abbreviation, :banner_text, :logo, :remove_logo, :description, :domain,
+ attr_accessible :abbreviation, :banner_text, :logo, :remove_logo, :domain,
:logo_file_name, :name, :stylesheet_file_id, :target_url,
:organisation_type_id, :wayfless_entity, :parent_id, :sort_name,
- :token_permission_type_ids, :language_id
+ :token_permission_type_ids, :language_id, :contact_email
+
+ validates :contact_email, email: true
# allow validations for logo upload
- dragonfly_accessor :logo
+ dragonfly_accessor :logo do
+ after_assign :resize_image
+ end
+
validates_property :height, of: :logo, in: (0..100)
validates_property :format, of: :logo, in: ['jpeg', 'png', 'gif','jpg','bmp']
validates_size_of :logo, maximum: 500.kilobytes
@@ -180,4 +186,16 @@
end
end
end
+
+ private
+ ##
+ # checks size of logo and resizes if necessary
+ #
+ def resize_image
+ unless logo.nil?
+ if logo.height != 100
+ self.logo = logo.thumb('x100') # resize height and maintain aspect ratio
+ end
+ end
+ end
end
diff --git a/app/validators/email_validator.rb b/app/validators/email_validator.rb
new file mode 100644
index 0000000..d47e7c1
--- /dev/null
+++ b/app/validators/email_validator.rb
@@ -0,0 +1,7 @@
+class EmailValidator < ActiveModel::EachValidator
+ def validate_each(record, attribute, value)
+ unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
+ record.errors[attribute] << (options[:message] || "is not a valid email address")
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/views/layouts/_dmponline_header.html.erb b/app/views/layouts/_dmponline_header.html.erb
index b80c58b..65c5036 100644
--- a/app/views/layouts/_dmponline_header.html.erb
+++ b/app/views/layouts/_dmponline_header.html.erb
@@ -3,11 +3,7 @@
->>>>>>> d191694e1cedc43d310c37ca7ceae733e677fb03
+
diff --git a/config/initializers/dragonfly.rb b/config/initializers/dragonfly.rb
index 7e74f09..bfaa4e5 100644
--- a/config/initializers/dragonfly.rb
+++ b/config/initializers/dragonfly.rb
@@ -23,4 +23,4 @@
if defined?(ActiveRecord::Base)
ActiveRecord::Base.extend Dragonfly::Model
ActiveRecord::Base.extend Dragonfly::Model::Validations
-end
+end
\ No newline at end of file
diff --git a/config/locales/de.yml b/config/locales/de.yml
index 2090542..4ff6706 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -107,6 +107,12 @@
user_text_html: "Folgend findet sich die Liste von Benutzern registriert bzgl. Ihrer Organisation. Sie können diese Liste bzgl. aller Felder sortieren."
org_name: "Name"
org_abbr: "Abkürzung"
+ org_logo_failed_message: "Logo Upload fehlgeschlagen."
+ org_logo: "Logo"
+ org_contact_email: "Kontakt Email"
+ org_contact_email_help_text: "Die E-Mail -Adresse des Administrators in Ihrer Organisation. Ihre Benutzer werden diese Adresse verwenden, wenn sie Fragen haben."
+ new_org_logo: "Laden Sie ein neues Logo-Datei"
+ remove_logo: "Wenn Sie die Standard DMPRoadmap Logo verwenden entscheiden , prüfen Sie bitte dieses Feld Ihre aktuelle Logo zu entfernen."
org_desc: "Beschreibung"
org_target_url: "Web-Seite"
org_type: "Organisationsart"
diff --git a/config/locales/en-UK.yml b/config/locales/en-UK.yml
index 0ee0ccd..c930f82 100644
--- a/config/locales/en-UK.yml
+++ b/config/locales/en-UK.yml
@@ -141,6 +141,8 @@
org_details_label: "Organisation details"
org_text: "These are the basic details for your organisation."
org_abbr_help_text_html: "This is what displays as a label on your guidance, e.g. 'Glasgow guidance on Metadata'. It's best to use an abbreviation or short name."
+ org_contact_email: "Contact Email"
+ org_contact_email_help_text: "The email address of an administrator at your organisation. Your users will use this address if they have questions."
users_list: "List of users"
user_full_name: "Name"
user_name: "Email address"
@@ -149,10 +151,10 @@
user_text_html: "Below is a list of users registered for your organisation. You can sort the data by each field."
org_name: "Name"
org_abbr: "Abbreviation"
- org_logo_failed_message: "Logo Upload Failed. "
+ org_logo_failed_message: "Logo Upload Failed."
org_logo: "Logo"
new_org_logo: "Upload a new logo file"
- remove_logo: "If you decide to use the default DCC logo, please check this box to remove your current logo."
+ remove_logo: "If you decide to use the default DMPRoadmap logo, please check this box to remove your current logo."
org_desc: "Description"
org_banner_text: "Top banner text"
org_target_url: "Website"
diff --git a/config/locales/en-US.yml b/config/locales/en-US.yml
index 48e3742..8f7d952 100644
--- a/config/locales/en-US.yml
+++ b/config/locales/en-US.yml
@@ -141,6 +141,12 @@
user_text_html: "Below is a list of users registered for your organization. You can sort the data by each field."
org_name: "Name"
org_abbr: "Abbreviation"
+ org_logo_failed_message: "Logo Upload Failed."
+ org_logo: "Logo"
+ org_contact_email: "Contact Email"
+ org_contact_email_help_text: "The email address of an administrator at your organization. Your users will use this address if they have questions."
+ new_org_logo: "Upload a new logo file"
+ remove_logo: "If you decide to use the default DMPRoadmap logo, please check this box to remove your current logo."
org_desc: "Description"
org_banner_text: "Top banner text"
org_target_url: "Website"
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 89f8880..4b6f19e 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -114,6 +114,12 @@
user_text_html: " Vous trouverez ci-dessous une liste des utilisateurs inscrits pour votre organisme. Vous pouvez trier les données par champ."
org_name: "Nom"
org_abbr: "Abréviation"
+ org_logo_failed_message: "Logo Échec de l'envoi."
+ org_logo: "Logo"
+ org_contact_email: "Contact Email"
+ org_contact_email_help_text: "L' adresse e-mail d'un administrateur dans votre organisation. Vos utilisateurs utiliseront cette adresse si elles ont des questions."
+ new_org_logo: "Ajouter un nouveau fichier de logo"
+ remove_logo: "Si vous décidez d'utiliser le logo de DMPRoadmap par défaut , s'il vous plaît cocher cette case pour supprimer votre logo actuel."
org_desc: "Description"
org_target_url: "Site Web"
org_type: "Type d'organisme"
diff --git a/db/migrate/20160822130601_remove_description_from_organisation.rb b/db/migrate/20160822130601_remove_description_from_organisation.rb
new file mode 100644
index 0000000..0761ad5
--- /dev/null
+++ b/db/migrate/20160822130601_remove_description_from_organisation.rb
@@ -0,0 +1,5 @@
+class RemoveDescriptionFromOrganisation < ActiveRecord::Migration
+ def change
+ remove_column :organisations, :description
+ end
+end
diff --git a/db/migrate/20160822130701_add_contact_email_to_organisation.rb b/db/migrate/20160822130701_add_contact_email_to_organisation.rb
new file mode 100644
index 0000000..ae7cb3c
--- /dev/null
+++ b/db/migrate/20160822130701_add_contact_email_to_organisation.rb
@@ -0,0 +1,5 @@
+class AddContactEmailToOrganisation < ActiveRecord::Migration
+ def change
+ add_column :organisations, :contact_email, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 44466b9..c14f575 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,9 @@
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20160810193149) do
+
+ActiveRecord::Schema.define(version: 20160822130701) do
+
create_table "answers", force: :cascade do |t|
t.text "text", limit: 65535
t.integer "plan_id", limit: 4
@@ -31,8 +33,8 @@
t.integer "user_id", limit: 4
t.integer "question_id", limit: 4
t.text "text", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "archived"
t.integer "plan_id", limit: 4
t.integer "archived_by", limit: 4
@@ -85,7 +87,7 @@
end
create_table "friendly_id_slugs", force: :cascade do |t|
- t.string "slug", limit: 191, null: false
+ t.string "slug", limit: 255, null: false
t.integer "sluggable_id", limit: 4, null: false
t.string "sluggable_type", limit: 40
t.datetime "created_at"
@@ -98,8 +100,8 @@
create_table "guidance_groups", force: :cascade do |t|
t.string "name", limit: 255
t.integer "organisation_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "optional_subset"
t.boolean "published"
end
@@ -140,8 +142,8 @@
t.string "text", limit: 255
t.integer "number", limit: 4
t.boolean "is_default"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "org_token_permissions", force: :cascade do |t|
@@ -161,7 +163,6 @@
create_table "organisations", force: :cascade do |t|
t.string "name", limit: 255
t.string "abbreviation", limit: 255
- t.text "description", limit: 65535
t.string "target_url", limit: 255
t.integer "organisation_type_id", limit: 4
t.string "domain", limit: 255
@@ -178,6 +179,7 @@
t.integer "language_id", limit: 4
t.string "logo_uid", limit: 255
t.string "logo_name", limit: 255
+ t.string "contact_email", limit: 255
end
create_table "phases", force: :cascade do |t|
@@ -185,9 +187,9 @@
t.text "description", limit: 65535
t.integer "number", limit: 4
t.integer "dmptemplate_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "slug", limit: 191
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "slug", limit: 255
end
add_index "phases", ["dmptemplate_id"], name: "index_phases_on_dmptemplate_id", using: :btree
@@ -215,8 +217,8 @@
t.boolean "project_editor"
t.integer "user_id", limit: 4
t.integer "project_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "project_administrator"
end
@@ -230,9 +232,9 @@
create_table "projects", force: :cascade do |t|
t.string "title", limit: 255
t.integer "dmptemplate_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "slug", limit: 191
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "slug", limit: 255
t.integer "organisation_id", limit: 4
t.string "grant_number", limit: 255
t.string "identifier", limit: 255
@@ -286,9 +288,9 @@
end
create_table "roles", force: :cascade do |t|
- t.string "name", limit: 191
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.string "name", limit: 255
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "role_in_plans"
t.integer "resource_id", limit: 4
t.string "resource_type", limit: 255
@@ -303,18 +305,18 @@
t.integer "number", limit: 4
t.integer "version_id", limit: 4
t.integer "organisation_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "published"
end
create_table "settings", force: :cascade do |t|
- t.string "var", limit: 191, null: false
+ t.string "var", limit: 255, null: false
t.text "value", limit: 65535
t.integer "target_id", limit: 4, null: false
- t.string "target_type", limit: 191, null: false
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.string "target_type", limit: 255, null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
add_index "settings", ["target_type", "target_id", "var"], name: "index_settings_on_target_type_and_target_id_and_var", unique: true, using: :btree
@@ -329,8 +331,8 @@
t.integer "question_id", limit: 4
t.integer "organisation_id", limit: 4
t.text "text", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "is_example"
end
@@ -386,7 +388,7 @@
create_table "users", force: :cascade do |t|
t.string "firstname", limit: 255
t.string "surname", limit: 255
- t.string "email", limit: 191, default: "", null: false
+ t.string "email", limit: 255, default: "", null: false
t.string "orcid_id", limit: 255
t.string "shibboleth_id", limit: 255
t.integer "user_type_id", limit: 4
@@ -394,7 +396,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "encrypted_password", limit: 255, default: ""
- t.string "reset_password_token", limit: 191
+ t.string "reset_password_token", limit: 255
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", limit: 4, default: 0
@@ -402,15 +404,14 @@
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip", limit: 255
t.string "last_sign_in_ip", limit: 255
- t.string "confirmation_token", limit: 191
+ t.string "confirmation_token", limit: 255
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
- t.string "invitation_token", limit: 191
+ t.string "invitation_token", limit: 255
t.datetime "invitation_created_at"
t.datetime "invitation_sent_at"
t.datetime "invitation_accepted_at"
t.string "other_organisation", limit: 255
- t.boolean "dmponline3"
t.boolean "accept_terms"
t.integer "organisation_id", limit: 4
t.string "api_token", limit: 255