mumuki-domain 9.22.1 → 9.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/concerns/with_deleted_user.rb +29 -0
- data/app/models/discussion.rb +1 -1
- data/app/models/message.rb +0 -4
- data/app/models/user.rb +20 -17
- data/db/migrate/20211104182009_remove_sender_uid_from_messages.rb +5 -0
- data/lib/mumuki/domain/version.rb +1 -1
- data/lib/mumuki/domain.rb +2 -1
- metadata +18 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 91e7710d2d997039351f464c293d25fea0b8de59208431647e209dfaa67dad9c
|
|
4
|
+
data.tar.gz: eb4e1571ef6795874fda3a4871692af496fd322ad00009190cce5d3ee92c4fd2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 037fbb869e63fa550782f8fbb5c46993b3b901ca1c529d235f98982d86a450afcb7dcc47b1fd5cf39b2a3349c9993be9adc6c52d0a45cd95729a9b45a5d315ce
|
|
7
|
+
data.tar.gz: e2f2997b8479047321fcad632dabb65d0a4f2e24dabbe820da1150dcf38fc922add4a68666faed106930fb7e2dfe4a4c2cec26d3653cfe7c19bd3fda9ef7e16b
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module WithDeletedUser
|
|
2
|
+
def self.prepended(base)
|
|
3
|
+
super
|
|
4
|
+
base.before_destroy :forbid_destroy!, if: :deleted_user?
|
|
5
|
+
base.extend ClassMethods
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def deleted_user?
|
|
9
|
+
self == User.deleted_user
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def abbreviated_name
|
|
13
|
+
return super unless deleted_user?
|
|
14
|
+
|
|
15
|
+
I18n.t(:deleted_user, locale: (Organization.current.locale rescue 'en'))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
module ClassMethods
|
|
19
|
+
def deleted_user
|
|
20
|
+
@deleted_user ||= User.create_with(@buried_profile).find_or_create_by(uid: 'deleted:shibi')
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def forbid_destroy!
|
|
27
|
+
raise '"Deleted User" shibi cannot be destroyed'
|
|
28
|
+
end
|
|
29
|
+
end
|
data/app/models/discussion.rb
CHANGED
|
@@ -142,7 +142,7 @@ class Discussion < ApplicationRecord
|
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
def responses_count
|
|
145
|
-
visible_messages.where(
|
|
145
|
+
visible_messages.where.not(sender: initiator).count
|
|
146
146
|
end
|
|
147
147
|
|
|
148
148
|
def has_responses?
|
data/app/models/message.rb
CHANGED
data/app/models/user.rb
CHANGED
|
@@ -6,20 +6,30 @@ class User < ApplicationRecord
|
|
|
6
6
|
WithNotifications,
|
|
7
7
|
WithDiscussionCreation,
|
|
8
8
|
Awardee,
|
|
9
|
-
Disabling,
|
|
10
9
|
WithTermsAcceptance,
|
|
11
10
|
WithPreferences,
|
|
12
11
|
Onomastic,
|
|
13
12
|
Mumuki::Domain::Helpers::User
|
|
14
13
|
|
|
14
|
+
prepend WithDeletedUser
|
|
15
|
+
|
|
15
16
|
serialize :permissions, Mumukit::Auth::Permissions
|
|
16
17
|
serialize :ignored_notifications, Array
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
has_many :
|
|
21
|
-
has_many :
|
|
22
|
-
has_many :
|
|
19
|
+
before_destroy :clean_belongings!
|
|
20
|
+
|
|
21
|
+
has_many :api_clients, dependent: :delete_all
|
|
22
|
+
has_many :assignments, foreign_key: :submitter_id, dependent: :delete_all
|
|
23
|
+
has_many :certificates, dependent: :delete_all
|
|
24
|
+
has_many :exam_authorizations, dependent: :delete_all
|
|
25
|
+
has_many :exam_authorization_requests, dependent: :delete_all
|
|
26
|
+
has_many :notifications, dependent: :delete_all
|
|
27
|
+
has_many :indicators, dependent: :delete_all
|
|
28
|
+
has_many :user_stats, class_name: 'UserStats', dependent: :delete_all
|
|
29
|
+
|
|
30
|
+
has_many :discussions, foreign_key: :initiator_id
|
|
31
|
+
has_many :forum_messages, -> { where.not(discussion_id: nil) }, class_name: 'Message', foreign_key: :sender_id
|
|
32
|
+
has_many :direct_messages, -> { order(created_at: :desc) }, through: :assignments, source: :messages
|
|
23
33
|
|
|
24
34
|
has_many :submitted_exercises, through: :assignments, class_name: 'Exercise', source: :exercise
|
|
25
35
|
|
|
@@ -34,12 +44,8 @@ class User < ApplicationRecord
|
|
|
34
44
|
|
|
35
45
|
has_one :last_guide, through: :last_exercise, source: :guide
|
|
36
46
|
|
|
37
|
-
has_many :exam_authorizations
|
|
38
|
-
|
|
39
47
|
has_many :exams, through: :exam_authorizations
|
|
40
48
|
|
|
41
|
-
has_many :certificates
|
|
42
|
-
|
|
43
49
|
enum gender: %i(female male other unspecified)
|
|
44
50
|
belongs_to :avatar, polymorphic: true, optional: true
|
|
45
51
|
|
|
@@ -156,7 +162,6 @@ class User < ApplicationRecord
|
|
|
156
162
|
update! accepts_reminders: false
|
|
157
163
|
end
|
|
158
164
|
|
|
159
|
-
|
|
160
165
|
def attach!(role, course)
|
|
161
166
|
add_permission! role, course.slug
|
|
162
167
|
save_and_notify!
|
|
@@ -341,8 +346,10 @@ class User < ApplicationRecord
|
|
|
341
346
|
ignored_notifications.include? notification.subject
|
|
342
347
|
end
|
|
343
348
|
|
|
344
|
-
def
|
|
345
|
-
|
|
349
|
+
def clean_belongings!
|
|
350
|
+
discussions.update_all initiator_id: User.deleted_user.id
|
|
351
|
+
forum_messages.update_all sender_id: User.deleted_user.id
|
|
352
|
+
direct_messages.where(sender: self).delete_all
|
|
346
353
|
end
|
|
347
354
|
|
|
348
355
|
private
|
|
@@ -380,10 +387,6 @@ class User < ApplicationRecord
|
|
|
380
387
|
:uid
|
|
381
388
|
end
|
|
382
389
|
|
|
383
|
-
def self.unsubscription_verifier
|
|
384
|
-
Rails.application.message_verifier(:unsubscribe)
|
|
385
|
-
end
|
|
386
|
-
|
|
387
390
|
def self.create_if_necessary(user)
|
|
388
391
|
user[:uid] ||= user[:email]
|
|
389
392
|
where(uid: user[:uid]).first_or_create(user)
|
data/lib/mumuki/domain.rb
CHANGED
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.
|
|
4
|
+
version: 9.23.0
|
|
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-11-
|
|
11
|
+
date: 2021-11-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -24,6 +24,20 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: 5.1.6
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: email_validator
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.6'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.6'
|
|
27
41
|
- !ruby/object:Gem::Dependency
|
|
28
42
|
name: mumukit-auth
|
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -279,6 +293,7 @@ files:
|
|
|
279
293
|
- app/models/concerns/with_assignments.rb
|
|
280
294
|
- app/models/concerns/with_assignments_batch.rb
|
|
281
295
|
- app/models/concerns/with_case_insensitive_search.rb
|
|
296
|
+
- app/models/concerns/with_deleted_user.rb
|
|
282
297
|
- app/models/concerns/with_description.rb
|
|
283
298
|
- app/models/concerns/with_discussion_creation.rb
|
|
284
299
|
- app/models/concerns/with_discussion_creation/subscription.rb
|
|
@@ -690,6 +705,7 @@ files:
|
|
|
690
705
|
- db/migrate/20210929223144_add_authorization_requests_limit_to_exam_registration.rb
|
|
691
706
|
- db/migrate/20211004062332_reference_sender_via_id_in_messages.rb
|
|
692
707
|
- db/migrate/20211020224011_add_from_moderator_to_messages.rb
|
|
708
|
+
- db/migrate/20211104182009_remove_sender_uid_from_messages.rb
|
|
693
709
|
- lib/mumuki/domain.rb
|
|
694
710
|
- lib/mumuki/domain/area.rb
|
|
695
711
|
- lib/mumuki/domain/engine.rb
|