Initial commit
This commit is contained in:
2
app/assets/config/manifest.js
Normal file
2
app/assets/config/manifest.js
Normal file
@@ -0,0 +1,2 @@
|
||||
//= link_tree ../images
|
||||
//= link_directory ../stylesheets .css
|
||||
0
app/assets/images/.keep
Normal file
0
app/assets/images/.keep
Normal file
BIN
app/assets/images/concertiv-logo-std.png
Normal file
BIN
app/assets/images/concertiv-logo-std.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
83
app/assets/images/symbols.svg
Normal file
83
app/assets/images/symbols.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 239 KiB |
2
app/assets/javascripts/application.js
Normal file
2
app/assets/javascripts/application.js
Normal file
@@ -0,0 +1,2 @@
|
||||
//= require jquery
|
||||
//= require rails.validations
|
||||
15
app/assets/stylesheets/application.css
Normal file
15
app/assets/stylesheets/application.css
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||
* listed below.
|
||||
*
|
||||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
|
||||
* vendor/assets/stylesheets directory can be referenced here using a relative path.
|
||||
*
|
||||
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
||||
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
||||
* files in this directory. Styles in this file should be added after the last require_* statement.
|
||||
* It is generally better to create a new file per style scope.
|
||||
*
|
||||
*= require_tree .
|
||||
*= require_self
|
||||
*/
|
||||
1
app/assets/stylesheets/profiler.css
Normal file
1
app/assets/stylesheets/profiler.css
Normal file
File diff suppressed because one or more lines are too long
4
app/assets/stylesheets/vendor.css
Normal file
4
app/assets/stylesheets/vendor.css
Normal file
File diff suppressed because one or more lines are too long
4
app/channels/application_cable/channel.rb
Normal file
4
app/channels/application_cable/channel.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
module ApplicationCable
|
||||
class Channel < ActionCable::Channel::Base
|
||||
end
|
||||
end
|
||||
4
app/channels/application_cable/connection.rb
Normal file
4
app/channels/application_cable/connection.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
module ApplicationCable
|
||||
class Connection < ActionCable::Connection::Base
|
||||
end
|
||||
end
|
||||
2
app/controllers/application_controller.rb
Normal file
2
app/controllers/application_controller.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
end
|
||||
0
app/controllers/concerns/.keep
Normal file
0
app/controllers/concerns/.keep
Normal file
2
app/helpers/application_helper.rb
Normal file
2
app/helpers/application_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module ApplicationHelper
|
||||
end
|
||||
5
app/inputs/important_input.rb
Normal file
5
app/inputs/important_input.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class ImportantInput < Formtastic::Inputs::StringInput
|
||||
def to_html
|
||||
(" IMPORTANT " + super + " IMPORTANT ").html_safe
|
||||
end
|
||||
end
|
||||
6
app/javascript/channels/consumer.js
Normal file
6
app/javascript/channels/consumer.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// Action Cable provides the framework to deal with WebSockets in Rails.
|
||||
// You can generate new channels where WebSocket features live using the `bin/rails generate channel` command.
|
||||
|
||||
import { createConsumer } from "@rails/actioncable"
|
||||
|
||||
export default createConsumer()
|
||||
5
app/javascript/channels/index.js
Normal file
5
app/javascript/channels/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
// Load all the channels within this directory and all subdirectories.
|
||||
// Channel files must be named *_channel.js.
|
||||
|
||||
const channels = require.context('.', true, /_channel\.js$/)
|
||||
channels.keys().forEach(channels)
|
||||
13
app/javascript/packs/application.js
Normal file
13
app/javascript/packs/application.js
Normal file
@@ -0,0 +1,13 @@
|
||||
// This file is automatically compiled by Webpack, along with any other files
|
||||
// present in this directory. You're encouraged to place your actual application logic in
|
||||
// a relevant structure within app/javascript and only use these pack files to reference
|
||||
// that code so it'll be compiled.
|
||||
//
|
||||
import Rails from "@rails/ujs"
|
||||
import Turbolinks from "turbolinks"
|
||||
import * as ActiveStorage from "@rails/activestorage"
|
||||
import "channels"
|
||||
|
||||
Rails.start()
|
||||
Turbolinks.start()
|
||||
ActiveStorage.start()
|
||||
7
app/jobs/application_job.rb
Normal file
7
app/jobs/application_job.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class ApplicationJob < ActiveJob::Base
|
||||
# Automatically retry jobs that encountered a deadlock
|
||||
# retry_on ActiveRecord::Deadlocked
|
||||
|
||||
# Most jobs are safe to ignore if the underlying records are no longer available
|
||||
# discard_on ActiveJob::DeserializationError
|
||||
end
|
||||
4
app/mailers/application_mailer.rb
Normal file
4
app/mailers/application_mailer.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: 'from@example.com'
|
||||
layout 'mailer'
|
||||
end
|
||||
6
app/models/admin_user.rb
Normal file
6
app/models/admin_user.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class AdminUser < ApplicationRecord
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
||||
devise :database_authenticatable,
|
||||
:recoverable, :rememberable, :validatable
|
||||
end
|
||||
3
app/models/application_record.rb
Normal file
3
app/models/application_record.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
end
|
||||
0
app/models/concerns/.keep
Normal file
0
app/models/concerns/.keep
Normal file
7
app/models/concerns/recentable.rb
Normal file
7
app/models/concerns/recentable.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
module Recentable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
scope :recent, ->(number) { order("created_at DESC").limit(number) }
|
||||
end
|
||||
end
|
||||
8
app/models/employer.rb
Normal file
8
app/models/employer.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class Employer < ApplicationRecord
|
||||
include Recentable
|
||||
|
||||
has_many :subscriptions
|
||||
|
||||
|
||||
|
||||
end
|
||||
3
app/models/product.rb
Normal file
3
app/models/product.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class Product < ApplicationRecord
|
||||
belongs_to :supplier
|
||||
end
|
||||
110
app/models/subscription.rb
Normal file
110
app/models/subscription.rb
Normal file
@@ -0,0 +1,110 @@
|
||||
class Subscription < ApplicationRecord
|
||||
include Recentable
|
||||
belongs_to :employer
|
||||
|
||||
belongs_to :series_successor, class_name: "Subscription", foreign_key: :series_successor_id, optional: true, inverse_of: :series_predecessor
|
||||
has_one :series_predecessor, -> { readonly }, class_name: "Subscription", foreign_key: :series_successor_id, inverse_of: :series_successor, dependent: :nullify
|
||||
|
||||
validates :name, length: { in: 2..255, allow_nil: true }
|
||||
validates :autorenew_duration, numericality: { greater_than: 0 }
|
||||
validates :starts_at, presence: true
|
||||
validate :ends_at_after_starts_at
|
||||
validate :ends_at_before_successor_starts
|
||||
validate :starts_at_after_predecessor_ends
|
||||
validate :autorenew_voided_at_after_starts_at
|
||||
validate :terminated_at_after_starts_at
|
||||
validate :autorenew_deadline_after_starts_at_and_before_ends_at
|
||||
validates :billing_frequency, presence: true
|
||||
|
||||
def ends_at_after_starts_at
|
||||
return if ends_at.blank? || starts_at.blank?
|
||||
|
||||
if ends_at < starts_at
|
||||
errors.add(:ends_at, "must be after the start date")
|
||||
end
|
||||
end
|
||||
|
||||
def ends_at_before_successor_starts
|
||||
return if series_successor.blank?
|
||||
|
||||
if ends_at.blank?
|
||||
errors.add(:ends_at, "is required for renewed records")
|
||||
return
|
||||
end
|
||||
|
||||
if ends_at >= series_successor.starts_at
|
||||
errors.add(:ends_at, "must be before its renewal's start date")
|
||||
end
|
||||
end
|
||||
|
||||
def starts_at_after_predecessor_ends
|
||||
return if series_predecessor.blank?
|
||||
|
||||
if starts_at.blank?
|
||||
errors.add(:starts_at, "is required for records with predecessors")
|
||||
return
|
||||
end
|
||||
|
||||
if starts_at <= series_predecessor.ends_at
|
||||
errors.add(:starts_at, "must be after its predecessor's end date")
|
||||
end
|
||||
end
|
||||
|
||||
# Either percentage or flat fare discount type must be set if product is in travel vertical
|
||||
def discount_type_set
|
||||
# If product not yet set, can't assume discount type not being set is an error
|
||||
return if !product
|
||||
|
||||
if has_percentage_discount_type.blank? && has_flat_fare_discount_type.blank?
|
||||
errors.add(:has_percentage_discount_type, "- At least one of has_percentage_discount_type and has_flat_fare_discount_type must be true")
|
||||
end
|
||||
end
|
||||
|
||||
# HACK: this is a temporary fix to work around the lack of atomic updates
|
||||
# for subscriptions and cycles.
|
||||
# TODO: https://concertiv.atlassian.net/browse/ENG-266 - fix by using Form Objects
|
||||
def sync_effective_at
|
||||
return if self.cycles.empty?
|
||||
|
||||
if self.cycles.length == 1
|
||||
self.cycles.first.effective_at = self.starts_at
|
||||
end
|
||||
end
|
||||
|
||||
def terminated_at_after_starts_at
|
||||
return if terminated_at.blank? || starts_at.blank?
|
||||
|
||||
if terminated_at < starts_at
|
||||
errors.add(:terminated_at, "must be after the start date")
|
||||
end
|
||||
end
|
||||
|
||||
def autorenew_voided_at_after_starts_at
|
||||
return if !is_autorenew
|
||||
return if autorenew_voided_at.blank? || starts_at.blank?
|
||||
|
||||
if autorenew_voided_at < starts_at
|
||||
errors.add(:autorenew_voided_at, "must be after the start date")
|
||||
end
|
||||
end
|
||||
|
||||
def autorenew_deadline_after_starts_at_and_before_ends_at
|
||||
return if !is_autorenew
|
||||
|
||||
if autorenew_deadline.blank?
|
||||
errors.add(:autorenew_deadline, "must be a valid date")
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if !starts_at.blank? && autorenew_deadline < starts_at
|
||||
errors.add(:autorenew_deadline, "must be after the start date")
|
||||
end
|
||||
|
||||
if !ends_at.blank? && autorenew_deadline > ends_at
|
||||
errors.add(:autorenew_deadline, "must be before the end date")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
3
app/models/supplier.rb
Normal file
3
app/models/supplier.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class Supplier < ApplicationRecord
|
||||
has_many :products
|
||||
end
|
||||
14
app/views/admin/employers/_form.html.erb
Normal file
14
app/views/admin/employers/_form.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<h1>Completely custom form</h1>
|
||||
|
||||
<%= semantic_form_for [:admin, @employer] do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :name, as: :important %>
|
||||
<%= f.input :logo_url %>
|
||||
<%= f.input :short_name %>
|
||||
<%= f.input :short_code %>
|
||||
<%= f.input :status, as: :select, collection: ["active","inactive"], include_blank: false %>
|
||||
<% end %>
|
||||
<%= f.actions %>
|
||||
<% end %>
|
||||
|
||||
|
||||
16
app/views/layouts/application.html.erb
Normal file
16
app/views/layouts/application.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Ssrconcept</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<%= csrf_meta_tags %>
|
||||
<%= csp_meta_tag %>
|
||||
|
||||
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
13
app/views/layouts/mailer.html.erb
Normal file
13
app/views/layouts/mailer.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<style>
|
||||
/* Email styles need to be inline */
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
1
app/views/layouts/mailer.text.erb
Normal file
1
app/views/layouts/mailer.text.erb
Normal file
@@ -0,0 +1 @@
|
||||
<%= yield %>
|
||||
227
app/views/layouts/rails_admin/application.html.erb
Normal file
227
app/views/layouts/rails_admin/application.html.erb
Normal file
File diff suppressed because one or more lines are too long
49
app/views/layouts/rails_admin/original_application.html.erb
Normal file
49
app/views/layouts/rails_admin/original_application.html.erb
Normal file
@@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" "http-equiv"="Content-Type">
|
||||
<meta content="NONE,NOARCHIVE" name="robots">
|
||||
<%= csrf_meta_tag %>
|
||||
<%= stylesheet_link_tag "rails_admin/rails_admin.css", :media => :all %>
|
||||
<%= javascript_include_tag "rails_admin/rails_admin.js" %>
|
||||
</head>
|
||||
<body class="rails_admin">
|
||||
<div id="loading" class="label label-warning" style="display:none; position:fixed; right:20px; bottom:20px; z-index:100000">
|
||||
<%= t('admin.loading') %>
|
||||
</div>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<%= link_to dashboard_path, class: "brand pjax" do %>
|
||||
<%= _get_plugin_name[0] || 'Rails' %>
|
||||
<small><%= _get_plugin_name[1] || 'Admin' %>
|
||||
<% end %>
|
||||
<div class="nav-collapse">
|
||||
<%= render :partial => 'layouts/rails_admin/secondary_navigation' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span3">
|
||||
<div class="well sidebar-nav">
|
||||
<ul class="nav nav-list">
|
||||
<%= main_navigation %>
|
||||
</ul>
|
||||
<ul class="nav nav-list">
|
||||
<%= static_navigation %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span9">
|
||||
<div class="row-fluid">
|
||||
<div class="content" data-pjax-container="1">
|
||||
<%= render :template => 'layouts/rails_admin/pjax' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
13
app/views/rails_admin/employers/_form.html.erb
Normal file
13
app/views/rails_admin/employers/_form.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<%= errors_summary_for broadcast %>
|
||||
|
||||
|
||||
<%= bootstrap_form_with model: model, local: true do |form| %>
|
||||
V <%= form.text_field :name %>
|
||||
<%= form.time_zone_select(:shoot_location_time_zone, nil, label: "Time zone of shoot location") %> <div class="row align-items-center text-center mt-4">
|
||||
<%= link_to t("shared.cancel"), [project, :broadcasts], class: "col-3 text-reset" %>
|
||||
<div class="col-9">
|
||||
<%= form.submit class: class_string("btn btn-block", ["btn-success", "btn-primary"] => broadcast.new_record?), data: { disable_with: t("shared.disable_with") } %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user