mumuki-domain 9.1.0 → 9.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/with_soft_deletion.rb +16 -0
- data/app/models/discussion.rb +8 -4
- data/app/models/exam_authorization_request.rb +11 -0
- data/app/models/message.rb +3 -2
- data/app/models/user.rb +6 -2
- data/db/migrate/20210318191512_add_deletion_fields_to_message.rb +7 -0
- data/lib/mumuki/domain/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 469928d18be5b255deb12fc4bf34681d5be7c4fd8ce1d19943e5d931152f89b6
|
4
|
+
data.tar.gz: 36afde0edf8b67cdfb86fd3f6b4b31df496a4a8e33081ca2f8497e34395a64a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f803662c7ac490c3531cb7adba534d871efb9e4b54bde3eb9f294971da09794834842892fbbc420d9fc4d231bb51372a76b0b06f021ac70f2fd74f844933284
|
7
|
+
data.tar.gz: 3001b4fa192a0065ed973d70b066612af5b739d1d144a41b037c89136fa06d9289f5d1e1c922063bf045502cab6aa8c02a8c238987ad34563ef0db92712f517c
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module WithSoftDeletion
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
enum deletion_motive: %i(self_deleted inappropriate_content shares_solution discloses_personal_information)
|
6
|
+
belongs_to :deleted_by, class_name: 'User', optional: true
|
7
|
+
end
|
8
|
+
|
9
|
+
def soft_delete!(motive, deleter)
|
10
|
+
update! deletion_motive: motive, deleted_by: deleter, deleted_at: Time.now
|
11
|
+
end
|
12
|
+
|
13
|
+
def deleted?
|
14
|
+
deleted_at.present?
|
15
|
+
end
|
16
|
+
end
|
data/app/models/discussion.rb
CHANGED
@@ -38,6 +38,10 @@ class Discussion < ApplicationRecord
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
def visible_messages
|
42
|
+
messages.where.not(deletion_motive: :self_deleted).or(messages.where(deletion_motive: nil))
|
43
|
+
end
|
44
|
+
|
41
45
|
def try_solve!
|
42
46
|
if opened?
|
43
47
|
update! status: reachable_statuses_for(initiator).first
|
@@ -73,7 +77,7 @@ class Discussion < ApplicationRecord
|
|
73
77
|
end
|
74
78
|
|
75
79
|
def last_message_date
|
76
|
-
|
80
|
+
visible_messages.last&.created_at || created_at
|
77
81
|
end
|
78
82
|
|
79
83
|
def friendly
|
@@ -125,11 +129,11 @@ class Discussion < ApplicationRecord
|
|
125
129
|
end
|
126
130
|
|
127
131
|
def has_messages?
|
128
|
-
|
132
|
+
visible_messages.exists? || description.present?
|
129
133
|
end
|
130
134
|
|
131
135
|
def responses_count
|
132
|
-
|
136
|
+
visible_messages.where.not(sender: initiator.uid).count
|
133
137
|
end
|
134
138
|
|
135
139
|
def has_responses?
|
@@ -186,6 +190,6 @@ class Discussion < ApplicationRecord
|
|
186
190
|
private
|
187
191
|
|
188
192
|
def messages_by_updated_at(direction = :desc)
|
189
|
-
messages.reorder(updated_at: direction)
|
193
|
+
messages.where(deletion_motive: nil).reorder(updated_at: direction)
|
190
194
|
end
|
191
195
|
end
|
@@ -18,6 +18,17 @@ class ExamAuthorizationRequest < ApplicationRecord
|
|
18
18
|
exam_registration.description
|
19
19
|
end
|
20
20
|
|
21
|
+
def icon
|
22
|
+
case status.to_sym
|
23
|
+
when :pending
|
24
|
+
{ class: 'info-circle', type: 'info' }
|
25
|
+
when :approved
|
26
|
+
{ class: 'check-circle', type: 'success' }
|
27
|
+
when :rejected
|
28
|
+
{ class: 'times-circle', type: 'danger' }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
21
32
|
private
|
22
33
|
|
23
34
|
def notify_user!
|
data/app/models/message.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
class Message < ApplicationRecord
|
2
|
+
include WithSoftDeletion
|
2
3
|
|
3
4
|
belongs_to :discussion, optional: true
|
4
5
|
belongs_to :assignment, foreign_key: :submission_id, primary_key: :submission_id, optional: true
|
@@ -10,7 +11,6 @@ class Message < ApplicationRecord
|
|
10
11
|
validates_presence_of :submission_id, :unless => :discussion_id?
|
11
12
|
|
12
13
|
after_save :update_counters_cache!
|
13
|
-
after_destroy :update_counters_cache!
|
14
14
|
|
15
15
|
markdown_on :content
|
16
16
|
|
@@ -43,7 +43,8 @@ class Message < ApplicationRecord
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def to_resource_h
|
46
|
-
as_json(except: [:id, :type, :discussion_id, :approved, :
|
46
|
+
as_json(except: [:id, :type, :discussion_id, :approved, :approved_at, :approved_by_id,
|
47
|
+
:not_actually_a_question, :deletion_motive, :deleted_at, :deleted_by_id],
|
47
48
|
include: {exercise: {only: [:bibliotheca_id]}})
|
48
49
|
.merge(organization: Organization.current.name)
|
49
50
|
end
|
data/app/models/user.rb
CHANGED
@@ -211,6 +211,10 @@ class User < ApplicationRecord
|
|
211
211
|
name.split.map(&:first).map(&:capitalize).join(' ')
|
212
212
|
end
|
213
213
|
|
214
|
+
def abbreviated_name
|
215
|
+
"#{first_name} #{last_name.first.capitalize + '.' if last_name.present?}".strip
|
216
|
+
end
|
217
|
+
|
214
218
|
def progress_at(content, organization)
|
215
219
|
Indicator.find_or_initialize_by(user: self, organization: organization, content: content)
|
216
220
|
end
|
@@ -283,11 +287,11 @@ class User < ApplicationRecord
|
|
283
287
|
end
|
284
288
|
|
285
289
|
def formal_first_name
|
286
|
-
verified_first_name || first_name
|
290
|
+
verified_first_name.presence || first_name
|
287
291
|
end
|
288
292
|
|
289
293
|
def formal_last_name
|
290
|
-
verified_last_name || last_name
|
294
|
+
verified_last_name.presence || last_name
|
291
295
|
end
|
292
296
|
|
293
297
|
def formal_full_name
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumuki-domain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.1.
|
4
|
+
version: 9.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franco Leonardo Bulgarelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -301,6 +301,7 @@ files:
|
|
301
301
|
- app/models/concerns/with_scoped_queries/page.rb
|
302
302
|
- app/models/concerns/with_scoped_queries/sort.rb
|
303
303
|
- app/models/concerns/with_slug.rb
|
304
|
+
- app/models/concerns/with_soft_deletion.rb
|
304
305
|
- app/models/concerns/with_target_audience.rb
|
305
306
|
- app/models/concerns/with_terms_acceptance.rb
|
306
307
|
- app/models/concerns/with_timed_enablement.rb
|
@@ -661,6 +662,7 @@ files:
|
|
661
662
|
- db/migrate/20210302181654_add_faqs_to_organizations.rb
|
662
663
|
- db/migrate/20210308145910_add_approved_by_and_at_to_message.rb
|
663
664
|
- db/migrate/20210310195602_add_delete_account_token_to_user.rb
|
665
|
+
- db/migrate/20210318191512_add_deletion_fields_to_message.rb
|
664
666
|
- db/migrate/20210318194559_add_dates_to_certificate_program.rb
|
665
667
|
- db/migrate/20210318195238_rename_certificate_dates.rb
|
666
668
|
- db/migrate/20210330175706_create_exam_registration_user_join_table.rb
|