ish_manager 0.1.8.402 → 0.1.8.404
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/ish_manager/iro_positions_controller.rb +45 -0
- data/app/controllers/ish_manager/iro_purses_controller.rb +2 -1
- data/app/helpers/ish_manager/application_helper.rb +6 -4
- data/app/mailers/ish_manager/application_mailer.rb +2 -2
- data/app/mailers/ish_manager/office_mailer.rb +2 -16
- data/app/views/ish_manager/application/_debug.haml +1 -0
- data/app/views/ish_manager/email_contexts/index.haml +3 -1
- data/app/views/ish_manager/iro_positions/_form.haml +34 -0
- data/app/views/ish_manager/iro_positions/edit.haml +3 -0
- data/app/views/ish_manager/iro_positions/new.haml +3 -0
- data/app/views/ish_manager/iro_purses/{my.haml → show.haml} +10 -5
- data/config/routes.rb +2 -1
- data/lib/tasks/office_tasks.rake +5 -32
- data/lib/tasks-done/migrate.rake +20 -0
- metadata +7 -4
- data/lib/tasks/ish_manager_tasks.rake +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b0e695973583101608da564e5460f74838147a078b52a29cab8c1aab34e9534
|
4
|
+
data.tar.gz: 16a23aa8e36df3e4ecee24a754516026017e40b9cc3f45e7a6b5cc81862d02e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cca17f65defbd1073a29f7fc5a6269864651083aaf6fdf1b5b2aeb63b432cb08e347d4e60c6b374405d25a4fae98414434fafc3490ca242e18e1b22740dd4e5
|
7
|
+
data.tar.gz: 2ca8c6173c2317cd453fef7b4c6057db8f0858d1b2b9ffa315e3aa5b86a00eea6c5ce5f0714ca05bc414b618a5483874e95386aaadfb7b5e19c528b4424edaff
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
class ::IshManager::IroPositionsController < IshManager::ApplicationController
|
3
|
+
|
4
|
+
before_action :set_lists
|
5
|
+
|
6
|
+
def create
|
7
|
+
@position = Iro::Position.new({
|
8
|
+
iro_purse: @purse = Iro::Purse.find_or_create_by({ user_id: current_user.id }),
|
9
|
+
type: 'Iro::CoveredCall',
|
10
|
+
})
|
11
|
+
authorize! :update, @position
|
12
|
+
|
13
|
+
if @position.update params[:position].permit!
|
14
|
+
flash[:notice] = 'Successfully updated position.'
|
15
|
+
redirect_to controller: 'iro_purses', action: :show
|
16
|
+
else
|
17
|
+
flash[:alert] = "Cannot update position: #{@position.errors.full_messages.join(', ')}."
|
18
|
+
render action: 'edit'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def edit
|
23
|
+
@position = Iro::Position.find params[:id]
|
24
|
+
authorize! :edit, @position
|
25
|
+
end
|
26
|
+
|
27
|
+
def new
|
28
|
+
@position = Iro::Position.new
|
29
|
+
authorize! :new, @position
|
30
|
+
end
|
31
|
+
|
32
|
+
def update
|
33
|
+
@position = Iro::Position.find params[:id]
|
34
|
+
authorize! :update, @position
|
35
|
+
|
36
|
+
if @position.update params[:position].permit!
|
37
|
+
flash[:notice] = 'Successfully updated position.'
|
38
|
+
redirect_to controller: 'iro_purses', action: :show
|
39
|
+
else
|
40
|
+
flash[:alert] = "Cannot update position: #{@position.errors.full_messages.join(', ')}."
|
41
|
+
render action: 'edit'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -3,10 +3,11 @@ class ::IshManager::IroPursesController < IshManager::ApplicationController
|
|
3
3
|
|
4
4
|
before_action :set_lists
|
5
5
|
|
6
|
-
def
|
6
|
+
def show
|
7
7
|
@purse = Iro::Purse.find_or_create_by({ user_id: current_user.id })
|
8
8
|
authorize! :my, @purse
|
9
9
|
@positions = @purse.positions.order({ expires_on: :asc, strike: :asc })
|
10
|
+
@positions.map &:refresh
|
10
11
|
@strategies = Iro::CoveredCallStrategy.where({
|
11
12
|
iro_purse_id: Iro::Purse.find_by( user_id: current_user.id ).id,
|
12
13
|
})
|
@@ -30,10 +30,6 @@ module IshManager
|
|
30
30
|
# "/manager/email_contexts/for_lead/#{lead.id.to_s}"
|
31
31
|
# end
|
32
32
|
|
33
|
-
def pretty_date input
|
34
|
-
return input.strftime("%Y-%m-%d")
|
35
|
-
end
|
36
|
-
|
37
33
|
def pp_errors errors
|
38
34
|
return errors
|
39
35
|
end
|
@@ -53,6 +49,12 @@ module IshManager
|
|
53
49
|
date&.strftime('%Y-%m-%d')
|
54
50
|
end
|
55
51
|
def pp_date a; pretty_date a; end
|
52
|
+
def pp_datetime date
|
53
|
+
date&.strftime('%Y-%m-%d %l:%M%P %z')
|
54
|
+
end
|
55
|
+
def pp_time date
|
56
|
+
date&.strftime('%l:%M%P %z')
|
57
|
+
end
|
56
58
|
|
57
59
|
def pp_amount a
|
58
60
|
return '-' if !a
|
@@ -12,7 +12,7 @@ module IshManager
|
|
12
12
|
@gallery_path = IshManager::Engine.routes.url_helpers.gallery_path(@gallery.slug)
|
13
13
|
mail( :to => '314658@gmail.com',
|
14
14
|
:bcc => profiles.map { |p| p.email },
|
15
|
-
:subject => 'You got new shared galleries on pi manager' )
|
15
|
+
:subject => 'You got new shared galleries on pi manager' )
|
16
16
|
end
|
17
17
|
|
18
18
|
def option_alert option
|
@@ -32,7 +32,7 @@ module IshManager
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_email
|
35
|
-
mail( to:
|
35
|
+
mail( to: DEFAULT_RECIPIENT, subject: "Test email at #{Time.now}" )
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
@@ -54,8 +54,9 @@ class IshManager::OfficeMailer < IshManager::ApplicationMailer
|
|
54
54
|
template_name: template )
|
55
55
|
end
|
56
56
|
|
57
|
+
## 2023-04-02 _vp_ Continue.
|
57
58
|
def send_context_email ctx_id
|
58
|
-
@ctx =
|
59
|
+
@ctx = Ctx.find ctx_id
|
59
60
|
ac = ActionController::Base.new
|
60
61
|
ac.instance_variable_set( :@ctx, @ctx )
|
61
62
|
|
@@ -69,18 +70,3 @@ class IshManager::OfficeMailer < IshManager::ApplicationMailer
|
|
69
70
|
end
|
70
71
|
|
71
72
|
end
|
72
|
-
|
73
|
-
|
74
|
-
## 2022-11-10 _vp_ backup
|
75
|
-
# def send_context_email ctx_id
|
76
|
-
# @email_ctx = ::Ish::EmailContext.find ctx_id
|
77
|
-
# template = "render/_#{@email_ctx.email_template.slug}"
|
78
|
-
# ac = ActionController::Base.new
|
79
|
-
# ac.instance_variable_set( :@email_ctx, @email_ctx )
|
80
|
-
# rendered_str = ac.render_to_string("ish_manager/email_templates/_#{@email_ctx.email_template.slug}")
|
81
|
-
# @email_ctx.update( rendered_str: rendered_str, sent_at: Time.now )
|
82
|
-
# mail( to: @email_ctx.to_email,
|
83
|
-
# bcc: 'piousbox@gmail.com',
|
84
|
-
# subject: @email_ctx.subject,
|
85
|
-
# template_name: template )
|
86
|
-
# end
|
@@ -44,7 +44,9 @@
|
|
44
44
|
= link_to email_context_path(ctx) do
|
45
45
|
= ctx.subject ? ctx.subject : "t| #{ctx.tmpl.subject}"
|
46
46
|
%td= ctx.email_template.slug
|
47
|
-
%td
|
47
|
+
%td.send_at
|
48
|
+
.a= pp_date ctx.send_at
|
49
|
+
.a= pp_time ctx.send_at
|
48
50
|
%td= pp_date ctx.sent_at
|
49
51
|
|
50
52
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
- url = position.new_record? ? iro_positions_path : iro_position_path( position )
|
3
|
+
|
4
|
+
.iro-positions--form
|
5
|
+
= form_for position, as: :position, url: url do |f|
|
6
|
+
.flex-row
|
7
|
+
.field Position ##{position.id}
|
8
|
+
.field
|
9
|
+
= f.label :strategy
|
10
|
+
= f.select :iro_strategy_id, options_for_select( Iro::CoveredCallStrategy.list, selected: position.iro_strategy_id ), {}, class: 'select2'
|
11
|
+
.field
|
12
|
+
= f.label :ticker
|
13
|
+
= f.text_field :ticker
|
14
|
+
|
15
|
+
.field
|
16
|
+
= f.label :strike
|
17
|
+
= f.number_field :strike, step: 0.01
|
18
|
+
|
19
|
+
.field
|
20
|
+
= f.label :expires_on
|
21
|
+
= f.text_field :expires_on
|
22
|
+
.field
|
23
|
+
= f.label :status
|
24
|
+
= f.select :status, options_for_select( Iro::Position.statuses_list, selected: position.status ), {}, class: 'select2'
|
25
|
+
|
26
|
+
.field
|
27
|
+
= f.label :opened_price
|
28
|
+
= f.text_field :opened_price
|
29
|
+
.field
|
30
|
+
= f.label :opened_on
|
31
|
+
= f.text_field :opened_on
|
32
|
+
|
33
|
+
.actions
|
34
|
+
= f.submit 'Submit'
|
@@ -1,9 +1,10 @@
|
|
1
1
|
|
2
2
|
.iro-purses-my.padded
|
3
3
|
.header
|
4
|
-
%h2.title
|
4
|
+
%h2.title Purse value: $#{@purse.current_value}
|
5
5
|
|
6
6
|
.strategies
|
7
|
+
.title Strategies
|
7
8
|
- @strategies.each do |strat|
|
8
9
|
.strategy
|
9
10
|
= link_to '[~]', edit_iro_strategy_path( strat )
|
@@ -11,13 +12,15 @@
|
|
11
12
|
|
12
13
|
|
13
14
|
.positions
|
14
|
-
%h3
|
15
|
+
%h3
|
16
|
+
Positions (#{@positions.length})
|
17
|
+
= link_to '[+]', new_iro_position_path
|
15
18
|
|
16
19
|
%table.bordered
|
17
20
|
%thead
|
18
21
|
%tr
|
19
22
|
%td id
|
20
|
-
%td
|
23
|
+
%td Strategy
|
21
24
|
%td Ticker
|
22
25
|
%td Kind/Type
|
23
26
|
%td Strike
|
@@ -40,8 +43,10 @@
|
|
40
43
|
%tbody
|
41
44
|
- @positions.each do |p|
|
42
45
|
%tr
|
43
|
-
%td
|
44
|
-
|
46
|
+
%td
|
47
|
+
= p.id
|
48
|
+
= link_to '[~]', edit_iro_position_path(p)
|
49
|
+
%td= p.strategy
|
45
50
|
%td= p.ticker
|
46
51
|
%td= p.type == "Iro::CoveredCall" ? "CALL" : "other"
|
47
52
|
%td= p.strike
|
data/config/routes.rb
CHANGED
@@ -25,10 +25,11 @@ IshManager::Engine.routes.draw do
|
|
25
25
|
# end
|
26
26
|
# resources :orders
|
27
27
|
|
28
|
+
resources :iro_positions
|
28
29
|
|
29
30
|
# get 'iro_watches', to: 'iro_watches#index'
|
30
31
|
resources :iro_watches
|
31
|
-
get 'iro_purse', to: 'iro_purses#
|
32
|
+
get 'iro_purse', to: 'iro_purses#show', as: :my_purse
|
32
33
|
|
33
34
|
resources :iro_strategies
|
34
35
|
|
data/lib/tasks/office_tasks.rake
CHANGED
@@ -1,9 +1,4 @@
|
|
1
1
|
|
2
|
-
def puts! a, b=''
|
3
|
-
puts "+++ +++ #{b}"
|
4
|
-
puts a.inspect
|
5
|
-
end
|
6
|
-
|
7
2
|
namespace :office do
|
8
3
|
|
9
4
|
desc 'scheduled email actions, rolling perform'
|
@@ -11,34 +6,10 @@ namespace :office do
|
|
11
6
|
while true do
|
12
7
|
|
13
8
|
Sch.active.where({ :perform_at.lte => Time.now }).each do |sch|
|
14
|
-
sch.update_attributes({ state: Sch::STATE_INACTIVE })
|
15
9
|
|
16
|
-
|
17
|
-
ctx = Ctx.new({
|
18
|
-
email_template_id: sch.act.tmpl.id,
|
19
|
-
lead_id: sch.lead.id,
|
20
|
-
send_at: Time.now,
|
21
|
-
subject: sch.act.tmpl.subject,
|
22
|
-
from_email: sch.act.tmpl.from_email,
|
23
|
-
scheduled_email_action_id: sch.act.id,
|
24
|
-
})
|
25
|
-
ctx.save!
|
26
|
-
|
27
|
-
# schedule next actions & update the action
|
28
|
-
sch.act.ties.each do |tie|
|
29
|
-
next_act = tie.next_email_action
|
30
|
-
next_at = eval(tie.next_at_exe)
|
31
|
-
next_sch = Sch.find_or_initialize_by({
|
32
|
-
lead_id: sch.lead_id,
|
33
|
-
email_action_id: next_act.id,
|
34
|
-
})
|
35
|
-
next_sch.perform_at = next_at
|
36
|
-
next_sch.state = Sch::STATE_ACTIVE
|
37
|
-
next_sch.save!
|
38
|
-
end
|
10
|
+
sch.send_and_roll
|
39
11
|
|
40
12
|
print '+'
|
41
|
-
|
42
13
|
end
|
43
14
|
|
44
15
|
# sleep 1.minute
|
@@ -47,13 +18,15 @@ namespace :office do
|
|
47
18
|
end
|
48
19
|
end
|
49
20
|
|
21
|
+
## 2023-04-02 _vp_ Continue.
|
50
22
|
desc "send emails"
|
51
|
-
task
|
23
|
+
task ctxs: :environment do
|
52
24
|
while true do
|
53
25
|
|
54
26
|
ctxs = ::Ish::EmailContext.scheduled.notsent
|
55
27
|
ctxs.map do |ctx|
|
56
|
-
IshManager::OfficeMailer.send_context_email( ctx[:id].to_s )
|
28
|
+
out = IshManager::OfficeMailer.send_context_email( ctx[:id].to_s )
|
29
|
+
Rails.env.production? ? out.deliver_later : out.deliver_now
|
57
30
|
print '^'
|
58
31
|
end
|
59
32
|
|
data/lib/tasks-done/migrate.rake
CHANGED
@@ -30,5 +30,25 @@ namespace :migrate do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
desc "every user needs a user_profile"
|
34
|
+
task :generate_user_profiles => :environment do
|
35
|
+
User.all.map do |u|
|
36
|
+
unless u.profile
|
37
|
+
p = ::Ish::UserProfile.new :email => u.email, :user => u, :role_name => :guy
|
38
|
+
u.profile = p
|
39
|
+
u.save && p.save && print('.')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
puts 'OK'
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'assign my creator_profile to Gameui::Marker where missing'
|
46
|
+
task :gameui_markers_creator_profile => :environment do
|
47
|
+
ms = Gameui::Marker.where( creator_profile_id: nil )
|
48
|
+
profile = User.find_by( email: 'piousbox@gmail.com' ).profile
|
49
|
+
ms.update_all( creator_profile_id: profile.id )
|
50
|
+
end
|
51
|
+
|
52
|
+
|
33
53
|
end
|
34
54
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ish_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.8.
|
4
|
+
version: 0.1.8.404
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -320,6 +320,7 @@ files:
|
|
320
320
|
- app/controllers/ish_manager/galleries_controller.rb
|
321
321
|
- app/controllers/ish_manager/image_assets_controller.rb
|
322
322
|
- app/controllers/ish_manager/invoices_controller.rb
|
323
|
+
- app/controllers/ish_manager/iro_positions_controller.rb
|
323
324
|
- app/controllers/ish_manager/iro_purses_controller.rb
|
324
325
|
- app/controllers/ish_manager/iro_strategies_controller.rb
|
325
326
|
- app/controllers/ish_manager/iro_watches_controller.rb
|
@@ -478,7 +479,10 @@ files:
|
|
478
479
|
- app/views/ish_manager/iro_mailer/condor_followup_alerb.html.erb
|
479
480
|
- app/views/ish_manager/iro_mailer/option_alert.html.erb
|
480
481
|
- app/views/ish_manager/iro_mailer/stock_alert.html.erb
|
481
|
-
- app/views/ish_manager/
|
482
|
+
- app/views/ish_manager/iro_positions/_form.haml
|
483
|
+
- app/views/ish_manager/iro_positions/edit.haml
|
484
|
+
- app/views/ish_manager/iro_positions/new.haml
|
485
|
+
- app/views/ish_manager/iro_purses/show.haml
|
482
486
|
- app/views/ish_manager/iro_strategies/_form.haml
|
483
487
|
- app/views/ish_manager/iro_strategies/edit.haml
|
484
488
|
- app/views/ish_manager/iro_strategies/new.haml
|
@@ -594,7 +598,6 @@ files:
|
|
594
598
|
- lib/systemd/system/stockwatcher.service
|
595
599
|
- lib/systemd/system/watch_stocks.service
|
596
600
|
- lib/tasks-done/migrate.rake
|
597
|
-
- lib/tasks/ish_manager_tasks.rake
|
598
601
|
- lib/tasks/office_tasks.rake
|
599
602
|
homepage: http://wasya.co
|
600
603
|
licenses:
|
@@ -1,29 +0,0 @@
|
|
1
|
-
|
2
|
-
def puts! a, b=''
|
3
|
-
puts "+++ +++ #{b}"
|
4
|
-
puts a.inspect
|
5
|
-
end
|
6
|
-
|
7
|
-
namespace :ish_manager do
|
8
|
-
|
9
|
-
desc "every user needs a user_profile"
|
10
|
-
task :generate_user_profiles => :environment do
|
11
|
-
User.all.map do |u|
|
12
|
-
unless u.profile
|
13
|
-
p = ::Ish::UserProfile.new :email => u.email, :user => u, :role_name => :guy
|
14
|
-
u.profile = p
|
15
|
-
u.save && p.save && print('.')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
puts 'OK'
|
19
|
-
end
|
20
|
-
|
21
|
-
desc 'assign my creator_profile to Gameui::Marker where missing'
|
22
|
-
task :gameui_markers_creator_profile => :environment do
|
23
|
-
ms = Gameui::Marker.where( creator_profile_id: nil )
|
24
|
-
profile = User.find_by( email: 'piousbox@gmail.com' ).profile
|
25
|
-
ms.update_all( creator_profile_id: profile.id )
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
end
|