Commit ce83a49bfef897e5abfefcd1793cd721fe935d84
1 parent
e7eecf9f
Exists in
master
and in
3 other branches
add institution to community rating
Signed-off-by: DylanGuedes <djmgguedes@gmail.com> Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Showing
5 changed files
with
41 additions
and
6 deletions
Show diff stats
db/migrate/20150714123613_add_institution_to_community_rating.rb
0 → 100644
| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | +require_dependency "community_rating" | |
| 2 | + | |
| 3 | +CommunityRating.class_eval do | |
| 4 | + attr_accessible :institution_id | |
| 5 | + | |
| 6 | + belongs_to :institution | |
| 7 | + | |
| 8 | + validate :verify_institution | |
| 9 | + | |
| 10 | + private | |
| 11 | + | |
| 12 | + def verify_institution | |
| 13 | + if self.institution_id != nil | |
| 14 | + institution = Institution.find_by_id self.institution_id | |
| 15 | + self.errors.add :institution, _("not found") unless institution | |
| 16 | + end | |
| 17 | + end | |
| 18 | +end | ... | ... |
lib/institution.rb
public/views/gov-user-comments-extra-fields.js
| ... | ... | @@ -5,11 +5,11 @@ modulejs.define("GovUserCommentsExtraFields", ['jquery','CreateInstitution'], fu |
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | |
| 8 | - function prepend_to_aditional_information() { | |
| 9 | - var aditional_information = $(".comments-software-extra-fields"); | |
| 10 | - var institution_comments = $("#input_institution_comments"); | |
| 8 | + function prepend_to_additional_information() { | |
| 9 | + var additional_information = $("#comments-additional-information"); | |
| 10 | + var institution_comments = $("#input_institution_comments").remove(); | |
| 11 | 11 | |
| 12 | - aditional_information.prepend(institution_comments.remove()); | |
| 12 | + institution_comments.insertAfter(additional_information); | |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | |
| ... | ... | @@ -19,7 +19,7 @@ modulejs.define("GovUserCommentsExtraFields", ['jquery','CreateInstitution'], fu |
| 19 | 19 | }, |
| 20 | 20 | |
| 21 | 21 | init: function() { |
| 22 | - prepend_to_aditional_information(); | |
| 22 | + prepend_to_additional_information(); | |
| 23 | 23 | set_events(); |
| 24 | 24 | } |
| 25 | 25 | } | ... | ... |
views/comments_extra_field.html.erb
| 1 | 1 | <div id="input_institution_comments"> |
| 2 | 2 | <%= label_tag "input_institution", _("Organiztion name or Enterprise name")%> |
| 3 | - <%= text_field_tag "comments[instituton_name]", "", id: "input_institution" %> | |
| 3 | + | |
| 4 | + <input type="text" id="input_institution"> | |
| 5 | + | |
| 4 | 6 | <%= content_tag(:div, _("No institution found"), |
| 5 | 7 | :id=>"institution_empty_ajax_message", |
| 6 | 8 | :class=>"errorExplanation hide-field") %> |
| 9 | + <%= hidden_field_tag "community_rating[institution_id]", "", id: "institution_selected" %> | |
| 7 | 10 | </div> | ... | ... |