lato 0.1.57 → 0.1.58

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: 8124b34e4bbd5bc9858fe5016ac06c7978acf8b0b0106c440cfb8abbaf805735
4
- data.tar.gz: ee86acb19e3d81233fbc1b5adecffda2595005c752eb612a56072d967bd224bd
3
+ metadata.gz: 0b79cd0a33c8c91953c951e6f4dea60bf2beef77f331c17b739968ee9e39f9a5
4
+ data.tar.gz: bebe365be7fff9fb9b387c47dbfede50d65d3beb05a54a9c966237404057fa19
5
5
  SHA512:
6
- metadata.gz: 2e3a0c4e8b55176d77078c17d096a3ea7ba2f9568193594eac3fc1fc0d8c64fe523e1ab778eae9e9dcbdf979baecbd1bd82b8d45b240fe8818f710029bd086f5
7
- data.tar.gz: a423547cef8c1ef0da6ec206305afa3acc34ad8a29bdf404e1c506bc6a63d50212aacdcc31daef0068d4043283acceaf5547ed5af3882afa20313e5188607854
6
+ metadata.gz: 7af7ef22e2495eaf79a71bfc56846f62c6d2af6bcafe9d2ea51a17a688cdff63ab3d5fc208b1ee593d92e311c973af71df3a5e2a77c81657a44837fe2d148796
7
+ data.tar.gz: a653ffc2be2309c20747bb5356e79e3c4defa3fe2899c3cbeb505abcbde2fcc40e57ef9c2818c3640469df2587aedd82f5b8eea15ba37da055683d14756d19f2
@@ -1,5 +1,22 @@
1
1
  /** Import dependencies */
2
2
 
3
+ $primary: #03256c !default;
4
+ $secondary: #1768ac !default;
5
+ $success: #007a34 !default;
6
+ $danger: #f50032 !default;
7
+ $warning: #ffcc00 !default;
8
+ $info: #0017ed !default;
9
+
10
+ $gray-100: #ebeff4 !default;
11
+ $gray-200: #dde3e9 !default;
12
+ $gray-300: #d3dae1 !default;
13
+ $gray-400: #c3ccd5 !default;
14
+ $gray-500: #a4afba !default;
15
+ $gray-600: #66727d !default;
16
+ $gray-700: #454f58 !default;
17
+ $gray-800: #313a42 !default;
18
+ $gray-900: #1f262c !default;
19
+
3
20
  @import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css");
4
21
  @import "bootstrap";
5
22
 
@@ -48,7 +48,7 @@ module Lato
48
48
  @user = Lato::User.new(registration_params)
49
49
 
50
50
  respond_to do |format|
51
- if @user.save
51
+ if @user.signup(ip_address: request.remote_ip, user_agent: request.user_agent)
52
52
  session_create(@user.id)
53
53
 
54
54
  format.html { redirect_to lato.root_path }
@@ -5,24 +5,26 @@ module Lato
5
5
 
6
6
  protected
7
7
 
8
+ # This method is used to check if the job is running inside an operation.
8
9
  def operation?
9
10
  !!@operation
10
11
  end
11
12
 
13
+ # This method returns the input file attached to the operation if exists.
12
14
  def operation_input_file_attachment
13
15
  @operation.input_file.attached? ? @operation.input_file : nil
14
16
  end
15
17
 
18
+ # This method can be used to update the percentage of the operation.
16
19
  def update_operation_percentage(percentage)
17
20
  return false unless operation?
18
21
 
19
22
  @operation.update(
20
23
  percentage: percentage
21
24
  )
22
-
23
- true
24
25
  end
25
26
 
27
+ # This method can be used to save a file as output of the operation.
26
28
  def save_operation_output_file(file_path)
27
29
  return false unless operation?
28
30
 
@@ -32,10 +34,9 @@ module Lato
32
34
  io: file,
33
35
  filename: file_name
34
36
  )
35
-
36
- true
37
37
  end
38
38
 
39
+ # This method can be used to save a text message as output of the operation.
39
40
  def save_operation_output_message(message)
40
41
  return false unless operation?
41
42
 
@@ -48,6 +49,7 @@ module Lato
48
49
 
49
50
  private
50
51
 
52
+ # This function is used to manage the operation and manage custom errors.
51
53
  def manage_operation
52
54
  @operation = Lato::Operation.find(arguments.first[:_operation_id]) if arguments.first && arguments.first.is_a?(Hash) && !arguments.first[:_operation_id].blank?
53
55
  @operation&.running
@@ -0,0 +1,15 @@
1
+ module Lato
2
+ class Log::UserSignup < ApplicationRecord
3
+ # Relations
4
+ ##
5
+
6
+ belongs_to :lato_user, class_name: 'Lato::User', foreign_key: :lato_user_id, optional: true
7
+
8
+ # Hooks
9
+ ##
10
+
11
+ before_destroy do
12
+ throw :abort
13
+ end
14
+ end
15
+ end
@@ -1,7 +1,7 @@
1
1
  module Lato
2
2
  module Log
3
3
  def self.table_name_prefix
4
- 'lato_log_'
4
+ "lato_log_"
5
5
  end
6
6
  end
7
7
  end
@@ -10,6 +10,11 @@ module Lato
10
10
  has_one_attached :input_file
11
11
  has_one_attached :output_file
12
12
 
13
+ # Validations
14
+ ##
15
+
16
+ validates :percentage, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 100 }, allow_nil: true
17
+
13
18
  # Relations
14
19
  ##
15
20
 
@@ -28,6 +28,7 @@ module Lato
28
28
  has_many :lato_invitations_as_inviter, class_name: 'Lato::Invitation', foreign_key: :inviter_lato_user_id, dependent: :nullify
29
29
 
30
30
  has_many :lato_log_user_signins, class_name: 'Lato::Log::UserSignin', foreign_key: :lato_user_id, dependent: :nullify
31
+ has_many :lato_log_user_signups, class_name: 'Lato::Log::UserSignup', foreign_key: :lato_user_id, dependent: :nullify
31
32
 
32
33
  # Hooks
33
34
  ##
@@ -67,6 +68,21 @@ module Lato
67
68
  # Operations
68
69
  ##
69
70
 
71
+ def signup(params = {})
72
+ return unless save
73
+
74
+ begin
75
+ lato_log_user_signups.create(
76
+ ip_address: params[:ip_address],
77
+ user_agent: params[:user_agent]
78
+ )
79
+ rescue StandardError => e
80
+ Rails.logger.error(e)
81
+ end
82
+
83
+ true
84
+ end
85
+
70
86
  def signin(params)
71
87
  self.email = params[:email]
72
88
 
@@ -0,0 +1,10 @@
1
+ class CreateLatoLogUserSignups < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :lato_log_user_signups do |t|
4
+ t.string :ip_address
5
+ t.string :user_agent
6
+ t.references :lato_user, index: true, foreign_key: true
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
data/lib/lato/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lato
2
- VERSION = "0.1.57"
2
+ VERSION = "0.1.58"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.57
4
+ version: 0.1.58
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-10 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -140,6 +140,7 @@ files:
140
140
  - app/models/lato/invitation.rb
141
141
  - app/models/lato/log.rb
142
142
  - app/models/lato/log/user_signin.rb
143
+ - app/models/lato/log/user_signup.rb
143
144
  - app/models/lato/operation.rb
144
145
  - app/models/lato/session.rb
145
146
  - app/models/lato/user.rb
@@ -199,6 +200,7 @@ files:
199
200
  - db/migrate/20230109054412_create_lato_log_user_signins.rb
200
201
  - db/migrate/20230109061533_create_lato_invitations.rb
201
202
  - db/migrate/20230212211748_add_inviter_lato_user_id_to_invitations.rb
203
+ - db/migrate/20230823165716_create_lato_log_user_signups.rb
202
204
  - lib/lato.rb
203
205
  - lib/lato/btstrap.rb
204
206
  - lib/lato/config.rb