Skip to content

Commit

Permalink
Merge pull request #543 from awesomefoundation/jcn/chapter-form-maxle…
Browse files Browse the repository at this point in the history
…ngth

Add validations and update Chapter editing form to enforce field lengths
  • Loading branch information
jcn authored Apr 3, 2024
2 parents 0462e34 + 7f64d1f commit 128e73b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 2 additions & 0 deletions app/models/chapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Chapter < ApplicationRecord
validates_presence_of :slug
validates_uniqueness_of :name

validates :name, :slug, :twitter_url, :facebook_url, :instagram_url, :email_address, :blog_url, :rss_feed_url, :extra_question_1, :extra_question_2, :extra_question_3, length: {maximum: 255}

validates_format_of :slug, :with => /\A[a-z0-9-]+\Z/

def self.any_chapter
Expand Down
28 changes: 14 additions & 14 deletions app/views/chapters/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<%= simple_form_for chapter do |form| -%>
<% if current_user.can_create_chapters? %>
<div class="chapter-admin">
<%= form.input :inactive, :as => :boolean %>
<%= form.input :inactive, as: :boolean %>
</div>
<% end %>

<%= form.input :name %>
<%= form.input :slug %>
<%= form.input :twitter_url %>
<%= form.input :facebook_url %>
<%= form.input :instagram_url %>
<%= form.input :email_address %>
<%= form.input :blog_url %>
<%= form.input :rss_feed_url %>
<%= form.input :name, maxlength: true %>
<%= form.input :slug, maxlength: true %>
<%= form.input :twitter_url, maxlength: true %>
<%= form.input :facebook_url, maxlength: true %>
<%= form.input :instagram_url, maxlength: true %>
<%= form.input :email_address, maxlength: true %>
<%= form.input :blog_url, maxlength: true %>
<%= form.input :rss_feed_url, maxlength: true %>
<%= form.input :description %>
<%= form.input :hide_trustees %>
<%= form.input :country do %>
<% form.select :country, CountryOptions.countries_for_select(include_blank: true, selected: form.object.country) %>
<% end %>
<%= form.input :time_zone %>
<%= form.input :locale, :collection => I18n.available_locales, :include_blank => false, :label => t('simple_form.labels.chapter.locale', :slug => chapter.slug) %>
<%= form.input :locale, collection: I18n.available_locales, include_blank: false, label: t('simple_form.labels.chapter.locale', slug: chapter.slug) %>

<hr />

<%= form.input :application_intro, maxlength: 1000 %>
<%= form.input :extra_question_1 %>
<%= form.input :extra_question_2 %>
<%= form.input :extra_question_3 %>
<%= form.input :submission_response_email, :input_html => { :placeholder => Chapter::DEFAULT_SUBMISSION_RESPONSE_EMAIL } %>
<%= form.input :extra_question_1, maxlength: true %>
<%= form.input :extra_question_2, maxlength: true %>
<%= form.input :extra_question_3, maxlength: true %>
<%= form.input :submission_response_email, input_html: {placeholder: Chapter::DEFAULT_SUBMISSION_RESPONSE_EMAIL} %>

<%= form.button :submit %>
<% end -%>

0 comments on commit 128e73b

Please sign in to comment.