ish_models 0.0.33.203 → 0.0.33.205

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d743720d7da4d999732d7d28b69fe0697eaa73423d8fbb8f00866409eb857ed6
4
- data.tar.gz: da958d68e0f40daedef7356725afba4a063713315e5ef756396355700f49f710
3
+ metadata.gz: 35fec87554c6b3a0cd0dd1ade92dca464df390c4d3a718d09744d621f7619541
4
+ data.tar.gz: 0b6ac843524f389c07653b4ab5897953e5db6a26eba4d53f3ab16dff559fcd4d
5
5
  SHA512:
6
- metadata.gz: 210e40b9e0033207fb621b7d999227b638187f62937836885691b96206b4950ef01c5818d67fbef9fa5b456d5cf41a83b0f9974beda2e677662677315ba46b71
7
- data.tar.gz: 6e0519979624398d04c9406f8ade0df6be50fa062f6dc8aafdf1cec5cd4a278efa4a57b7101f0b9023e849f51268da2274d1a188ddff61ad26752dfaadceed2f
6
+ metadata.gz: 90d7ae686679c20bdf871ead96a7e1268f1adac15f90427fdc414641e433dfe8102663354db4d9149610a3d8fff3d3f5b8eb656961e3a6b49f6a4750ef2fdc06
7
+ data.tar.gz: f5df4f1ee219aafbe30ed50e3a845c8be3063250e6749756bc7686da66d76c5df41009af9036c17d4dc822c817fb0f8fc93e46e1bb2ec6fc5bcf91cfa0e94b1d
@@ -1,13 +1,11 @@
1
-
2
- #
3
- # Sends a single email
4
- #
1
+ ##
2
+ ## Send a single email
3
+ ##
5
4
 
6
5
  class ::Ish::EmailContext
7
6
  include Mongoid::Document
8
7
  include Mongoid::Timestamps
9
8
 
10
- ## @TODO: probably rename it to slug
11
9
  field :slug
12
10
  validates_uniqueness_of :slug, allow_nil: true
13
11
 
@@ -22,34 +20,19 @@ class ::Ish::EmailContext
22
20
 
23
21
  PAGE_PARAM_NAME = 'email_contexts_page'
24
22
 
25
- FROM_EMAILS = [
26
- 'Infinite Shelter <hello@infiniteshelter.com>',
27
- 'Infinite Shelter <no-reply@infiniteshelter.com>',
28
- 'Victor Piousbox <piousbox@gmail.com>',
29
- 'Victor Piousbox <victor@piousbox.com>',
30
- 'Victor Piousbox <no-reply@piousbox.com>',
31
- 'Victor Piousbox <admin@wasya.co>',
32
- 'WasyaCo Consulting <hello@wasya.co>',
33
- 'WasyaCo Consulting <no-reply@wasya.co>',
34
- 'Victor Piousbox <victor@wasya.co>',
35
- ];
36
23
  field :from_email
37
- validates_presence_of :from_email
38
- def self.from_email_list
39
- [ [nil, nil] ] + FROM_EMAILS.map { |i| [i, i] }
40
- end
24
+ # validates_presence_of :from_email
41
25
 
42
26
  field :subject
43
- validates_presence_of :subject
27
+ # validates_presence_of :subject
44
28
 
45
29
  field :body
46
30
 
47
31
  belongs_to :email_template
48
- def tmpl
49
- email_template
50
- end
32
+ def tmpl; email_template; end
51
33
 
52
34
  belongs_to :scheduled_email_action, class_name: '::Office::ScheduledEmailAction', optional: true
35
+ def sch; scheduled_email_action; end
53
36
 
54
37
  field :rendered_str
55
38
 
@@ -57,16 +40,10 @@ class ::Ish::EmailContext
57
40
  field :send_at, type: DateTime
58
41
 
59
42
 
60
- def self.unsent
61
- new.unsent
62
- end
63
- def unsent
64
- Ish::EmailContext.where( sent_at: nil )
65
- end
43
+ def self.unsent; new.unsent; end
44
+ def unsent; Ish::EmailContext.where( sent_at: nil ); end
66
45
 
67
- def self.scheduled
68
- new.scheduled
69
- end
46
+ def self.scheduled; new.scheduled; end
70
47
  def scheduled
71
48
  # or({ :send_at.lte => Time.now }, { :send_at => nil }) ## This won't work b/c I need draft state!
72
49
  Ish::EmailContext.where({ :send_at.lte => Time.now })
@@ -74,12 +51,8 @@ class ::Ish::EmailContext
74
51
 
75
52
 
76
53
  field :lead_id, type: :integer
77
- def lead
78
- Lead.find lead_id
79
- end
80
- def to_email
81
- return lead[:email]
82
- end
54
+ def lead; Lead.find( lead_id ); end
55
+ def to_email; lead[:email]; end
83
56
 
84
57
 
85
58
  ##
@@ -21,7 +21,22 @@ class ::Ish::EmailTemplate
21
21
 
22
22
  field :subject
23
23
  field :body
24
+
25
+ FROM_EMAILS = [
26
+ 'Infinite Shelter <hello@infiniteshelter.com>',
27
+ 'Infinite Shelter <no-reply@infiniteshelter.com>',
28
+ 'Victor Piousbox <piousbox@gmail.com>',
29
+ 'Victor Piousbox <victor@piousbox.com>',
30
+ 'Victor Piousbox <no-reply@piousbox.com>',
31
+ 'Victor Piousbox <admin@wasya.co>',
32
+ 'WasyaCo Consulting <hello@wasya.co>',
33
+ 'WasyaCo Consulting <no-reply@wasya.co>',
34
+ 'Victor Piousbox <victor@wasya.co>',
35
+ ];
24
36
  field :from_email
37
+ def self.from_email_list
38
+ [ [nil, nil] ] + FROM_EMAILS.map { |i| [i, i] }
39
+ end
25
40
 
26
41
  ## 2023-03-04 _vp_ This works!
27
42
  def get_binding
data/lib/ish_models.rb CHANGED
@@ -8,9 +8,11 @@ require 'kaminari/mongoid'
8
8
 
9
9
  class Gameui; end
10
10
 
11
- # module Iro; end
12
- class Ish::InputError < RuntimeError; end
11
+ module Iro; end
12
+
13
+
13
14
  module Ish; end
15
+ class Ish::InputError < RuntimeError; end
14
16
 
15
17
  # I need this thing for permissions???
16
18
  class Manager; end
@@ -13,13 +13,17 @@ class Office::EmailAction
13
13
  field :descr, type: :string
14
14
 
15
15
  belongs_to :email_template, class_name: '::Ish::EmailTemplate'
16
+ def tmpl; email_template; end
16
17
 
17
- field :next_in_days, type: :string
18
- field :next_at_time, type: :string
18
+ # field :next_in_days, type: :string
19
+ # field :next_at_time, type: :string
20
+ field :next_at_exe, type: :string
19
21
 
20
22
  belongs_to :prev_email_action, class_name: '::Office::EmailAction', optional: true, inverse_of: :next_email_actions
21
23
  has_many :next_email_actions, class_name: '::Office::EmailAction', inverse_of: :prev_email_action
22
24
 
23
25
  has_many :scheduled_email_actions, class_name: '::Office::ScheduledEmailAction'
26
+ def schs; scheduled_email_actions; end
27
+
24
28
  end
25
29
 
@@ -41,18 +41,21 @@ class Office::EmailConversation
41
41
  else
42
42
  throw "#add_tag expects a WpTag or string (eg WpTag::EMAILTAG_INBOX) as the only parameter."
43
43
  end
44
- puts! tag, 'tag'
45
44
  self[:wp_term_ids] = ( [ tag.id ] + self[:wp_term_ids] ).uniq
46
45
  self.save!
47
46
  end
48
47
 
49
48
  def remove_tag tag
50
- if WpTag == tag.class
51
- self[:wp_term_ids].delete( tag.id )
52
- self.save!
49
+ case tag.class.name
50
+ when 'WpTag'
51
+ ;
52
+ when 'String'
53
+ tag = WpTag.emailtag(tag)
53
54
  else
54
- throw "#remove_tag expects a WpTag as the only parameter."
55
+ throw "#remove_tag expects a WpTag or string (eg WpTag::EMAILTAG_INBOX) as the only parameter."
55
56
  end
57
+ self[:wp_term_ids].delete( tag.id )
58
+ self.save!
56
59
  end
57
60
 
58
61
  def self.in_inbox
@@ -19,9 +19,13 @@ class Office::ScheduledEmailAction
19
19
  scope :active, ->{ where( state: STATE_ACTIVE ) }
20
20
 
21
21
  belongs_to :email_action, class_name: '::Office::EmailAction'
22
+ def act; email_action; end
23
+
22
24
  has_many :email_contexts, class_name: '::Ish::EmailContext'
25
+ def ctxs; email_contexts; end
26
+
27
+ field :perform_at, type: :time
23
28
 
24
- field :perform_at, type: :timestamp
25
29
 
26
30
  end
27
31
  ::Sch = Office::ScheduledEmailAction
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33.203
4
+ version: 0.0.33.205
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox