forked from idbygeorge/salsa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request idbygeorge#126 from keith-ferney/stage
should be able to start workflow for period and cycle and sequence
- Loading branch information
Showing
18 changed files
with
59 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
class Period < ApplicationRecord | ||
validates :slug, presence: true | ||
validates :start_date, presence: true | ||
validates :duration, presence: true | ||
validates :slug, uniqueness: { scope: :organization } | ||
validates_uniqueness_of :is_default, if: :is_default, scope: :organization, message: "is already set for this organization" | ||
|
||
belongs_to :organization | ||
has_many :documents | ||
|
||
def end_date | ||
self.start_date + self.duration.days if self.start_date && self.duration | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
db/migrate/20180820162331_remove_cycle_and_sequence_from_periods.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class RemoveCycleAndSequenceFromPeriods < ActiveRecord::Migration[5.1] | ||
def change | ||
remove_column :periods, :sequence, :integer | ||
remove_column :periods, :cycle, :string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
# Preview all emails at http://localhost:3000/rails/mailers/workflow_mailer | ||
class WorkflowMailerPreview < ActionMailer::Preview | ||
def step_email | ||
org = Organization.first | ||
org = Organization.find(2) | ||
orgs = org.parents.push(org) | ||
user = User.first | ||
step_slug = WorkflowStep.where(organization_id: orgs.map(&:id)).first.slug | ||
wfs = WorkflowStep.where(organization_id: orgs.map(&:id)).first | ||
step_slug = wfs.slug | ||
doc = Document.create(user_id: user.id, organization_id: orgs.map(&:id),workflow_step_id: wfs.id) | ||
allowed_variables = {"user_name" => "#{user&.name}","user_email" => "#{user&.email}", "organization_name" => "#{org&.name}", "step_slug" => "#{step_slug}"} | ||
WorkflowMailer.step_email(user,org,step_slug, allowed_variables) | ||
WorkflowMailer.step_email(doc, org.slug, user,org,step_slug, allowed_variables) | ||
end | ||
|
||
def welcome_email | ||
org = Organization.first | ||
org = Organization.find(2) | ||
orgs = org.parents.push(org) | ||
user = User.first | ||
step_slug = WorkflowStep.where(organization_id: orgs.map(&:id)).first.slug | ||
wfs = WorkflowStep.where(organization_id: orgs.map(&:id)).first | ||
step_slug = wfs.slug | ||
doc = Document.create(user_id: user.id, organization_id: orgs.map(&:id),workflow_step_id: wfs.id) | ||
allowed_variables = {"user_name" => "#{user&.name}","user_email" => "#{user&.email}", "organization_name" => "#{org&.name}", "step_slug" => "#{step_slug}"} | ||
WorkflowMailer.welcome_email(user,org,step_slug, allowed_variables) | ||
WorkflowMailer.welcome_email(doc, org.slug, user,org,step_slug, allowed_variables) | ||
end | ||
end |