Skip to content

Commit

Permalink
Merge pull request #55 from GSA/39/create-challenge-model
Browse files Browse the repository at this point in the history
[39] Create Rails Challenge model
  • Loading branch information
bilalhankins authored Jul 31, 2024
2 parents 1ca186f + 42c3f0f commit 30c3de9
Show file tree
Hide file tree
Showing 28 changed files with 408 additions and 5 deletions.
1 change: 0 additions & 1 deletion .rspec

This file was deleted.

8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ group :development, :test do

gem "rubocop"
gem "rspec-rails"
gem 'codeclimate-test-reporter'
gem "codeclimate-test-reporter"
end

group :development do
Expand All @@ -65,13 +65,13 @@ group :development do
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"

gem 'foreman'
gem "foreman"
end

group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
gem 'rspec_junit_formatter'
gem 'simplecov'
gem "rspec_junit_formatter"
gem "simplecov"
end
37 changes: 37 additions & 0 deletions app/models/agency.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: agencies
#
# id :bigint not null, primary key
# name :string(255) not null
# description :text
# avatar_key :uuid
# avatar_extension :string(255)
# deleted_at :datetime
# inserted_at :datetime not null
# updated_at :datetime not null
# created_on_import :boolean default(FALSE), not null
# acronym :string(255)
# parent_id :bigint
#
class Agency < ApplicationRecord
belongs_to :parent, class_name: 'Agency', optional: true
has_many :sub_agencies, class_name: 'Agency', foreign_key: :parent_id, dependent: :destroy, inverse_of: :parent
has_many :federal_partners, dependent: :destroy
has_many :federal_partner_challenges, through: :federal_partners, source: :challenge
has_many :members, dependent: :destroy
has_many :challenges, dependent: :destroy

attribute :acronym, :string
attribute :created_on_import, :boolean, default: false
attribute :description, :string
attribute :deleted_at, :datetime
attribute :name, :string
attribute :avatar_key, :uuid
attribute :avatar_extension, :string

validates :name, presence: true
validates :acronym, presence: true
end
178 changes: 178 additions & 0 deletions app/models/challenge.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: challenges
#
# id :bigint not null, primary key
# user_id :bigint not null
# description :text
# inserted_at :datetime not null
# updated_at :datetime not null
# status :string(255) default("pending"), not null
# captured_on :date
# published_on :date
# title :string(255)
# tagline :text
# poc_email :string(255)
# agency_name :string(255)
# how_to_enter :text
# rules :text
# external_url :string(255)
# custom_url :string(255)
# start_date :datetime
# end_date :datetime
# fiscal_year :string(255)
# type :string(255)
# prize_total :bigint not null
# prize_description :text
# judging_criteria :text
# challenge_manager :string(255)
# legal_authority :string(255)
# terms_and_conditions :text
# non_monetary_prizes :text
# federal_partners :text
# faq :text
# winner_information :text
# number_of_phases :text
# phase_descriptions :text
# phase_dates :text
# brief_description :text
# multi_phase :boolean
# eligibility_requirements :text
# challenge_manager_email :string(255)
# agency_id :bigint
# logo_key :uuid
# logo_extension :string(255)
# winner_image_key :uuid
# winner_image_extension :string(255)
# last_section :string(255)
# types :jsonb
# auto_publish_date :datetime
# deleted_at :datetime
# rejection_message :text
# phases :jsonb
# upload_logo :boolean
# is_multi_phase :boolean
# timeline_events :jsonb
# prize_type :string(255)
# terms_equal_rules :boolean
# how_to_enter_link :string(255)
# resource_banner_key :uuid
# resource_banner_extension :string(255)
# imported :boolean default(FALSE), not null
# description_delta :text
# prize_description_delta :text
# faq_delta :text
# eligibility_requirements_delta :text
# rules_delta :text
# terms_and_conditions_delta :text
# uuid :uuid
# sub_agency_id :bigint
# primary_type :string(255)
# other_type :string(255)
# announcement :text
# announcement_datetime :datetime
# sub_status :string(255)
# gov_delivery_topic :string(255)
# archive_date :datetime
# gov_delivery_subscribers :integer default(0), not null
# brief_description_delta :text
# logo_alt_text :string(255)
# short_url :string(255)
# submission_collection_method :string(255)
# file_upload_required :boolean default(FALSE)
# upload_instruction_note :string(255)
#
class Challenge < ApplicationRecord
belongs_to :user
belongs_to :agency
belongs_to :sub_agency, class_name: 'Agency', optional: true

has_many :events, dependent: :delete_all
has_many :supporting_documents, class_name: 'Document', dependent: :delete_all
has_many :challenge_managers, dependent: :delete_all
has_many :challenge_manager_users, through: :challenge_managers, source: :user
has_many :federal_partners, dependent: :delete_all
has_many :federal_partner_agencies, through: :federal_partners, source: :agency
has_many :non_federal_partners, dependent: :delete_all
has_many :phases, dependent: :destroy
has_many :submissions, dependent: :destroy
has_many :submission_exports, dependent: :destroy

# JSON fields
attribute :types, :jsonb
attribute :timeline_events, :jsonb
attribute :phases, :jsonb

attribute :status, :string, default: "draft"
attribute :prize_total, :integer, default: 0
attribute :gov_delivery_subscribers, :integer, default: 0
attribute :imported, :boolean, default: false
attribute :uuid, :uuid

# other fields
attribute :sub_status, :string
attribute :last_section, :string
attribute :challenge_manager, :string
attribute :challenge_manager_email, :string
attribute :poc_email, :string
attribute :agency_name, :string
attribute :title, :string
attribute :custom_url, :string
attribute :external_url, :string
attribute :tagline, :string
attribute :type, :string
attribute :description, :string
attribute :description_delta, :string
attribute :description_length, :integer
attribute :brief_description, :string
attribute :brief_description_delta, :string
attribute :brief_description_length, :integer
attribute :how_to_enter, :string
attribute :fiscal_year, :string
attribute :start_date, :datetime
attribute :end_date, :datetime
attribute :archive_date, :datetime
attribute :multi_phase, :boolean
attribute :number_of_phases, :string
attribute :phase_descriptions, :string
attribute :phase_dates, :string
attribute :judging_criteria, :string
attribute :prize_type, :string
attribute :non_monetary_prizes, :string
attribute :prize_description, :string
attribute :prize_description_delta, :string
attribute :prize_description_length, :integer
attribute :eligibility_requirements, :string
attribute :eligibility_requirements_delta, :string
attribute :rules, :string
attribute :rules_delta, :string
attribute :terms_and_conditions, :string
attribute :terms_and_conditions_delta, :string
attribute :legal_authority, :string
attribute :faq, :string
attribute :faq_delta, :string
attribute :faq_length, :integer
attribute :winner_information, :string
attribute :captured_on, :date
attribute :auto_publish_date, :datetime
attribute :published_on, :date
attribute :rejection_message, :string
attribute :how_to_enter_link, :string
attribute :announcement, :string
attribute :announcement_datetime, :datetime
attribute :gov_delivery_topic, :string
attribute :short_url, :string
attribute :upload_logo, :boolean
attribute :is_multi_phase, :boolean
attribute :terms_equal_rules, :boolean
attribute :file_upload_required, :boolean
attribute :upload_instruction_note, :string
attribute :submission_collection_method, :string

attribute :deleted_at, :datetime

validates :title, presence: true
validates :status, presence: true
end
2 changes: 2 additions & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
2 changes: 2 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative "../config/boot"
require "rake"
Rake.application.run
2 changes: 2 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "fileutils"

# path to your application root.
Expand Down
2 changes: 2 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true
#
# This file is used by Rack-based servers to start the application.

require_relative "config/environment"
Expand Down
2 changes: 2 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative "boot"

require "rails/all"
Expand Down
2 changes: 2 additions & 0 deletions config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

require "bundler/setup" # Set up gems listed in the Gemfile.
Expand Down
2 changes: 2 additions & 0 deletions config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true
#
# Load the Rails application.
require_relative "application"

Expand Down
2 changes: 2 additions & 0 deletions config/environments/dev.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/integer/time"

Rails.application.configure do
Expand Down
2 changes: 2 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/integer/time"

Rails.application.configure do
Expand Down
2 changes: 2 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/integer/time"

Rails.application.configure do
Expand Down
2 changes: 2 additions & 0 deletions config/environments/staging.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/integer/time"

Rails.application.configure do
Expand Down
2 changes: 2 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/integer/time"

# The test environment is used exclusively to run your application's
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Define an application-wide content security policy.
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/filter_parameter_logging.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/inflections.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Add new inflection rules using the following format. Inflections
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/permissions_policy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Define an application-wide HTTP permissions policy. For further
Expand Down
2 changes: 2 additions & 0 deletions config/puma.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This configuration file will be evaluated by Puma. The top-level methods that
# are invoked here are part of Puma's configuration DSL. For more information
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Rails.application.routes.draw do
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html

Expand Down
2 changes: 2 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file should ensure the existence of records required to run the application in every environment (production,
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
Expand Down
2 changes: 2 additions & 0 deletions spec/helpers/users_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

# Specs in this file have access to a helper object that includes
Expand Down
Loading

0 comments on commit 30c3de9

Please sign in to comment.