Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validations and update Chapter editing form to enforce field lengths #543

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 -%>
Loading