qalam_merit 4.5.07 → 4.5.08
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3d1f73f153930fdd73e1ba773d40feb481ab847a7d6857623779de05eacb8817
|
|
4
|
+
data.tar.gz: 62ddf64eecbb98665f47c841476fc1d5045813ff97db1bcf9c8fe8347c026f57
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8e1b99abd43904c894b2e75d590c0d901ab090a24a5f5d83fdd16af6c0307301a74ee93752e5c30f52a3281e763bb8132bb0a4ae14195ec546b29613c3cb6cb5
|
|
7
|
+
data.tar.gz: e976e63ad65c74580397199ea05e8f413a17a51834226066774b83c24517f8feb62cff128be39bb1e6c7e3ceccb338f15d21bfcd1e6121bc38ca94e183abb292
|
|
@@ -9,7 +9,6 @@ class CreateMeritBadges < ActiveRecord::Migration<%= migration_version %>
|
|
|
9
9
|
t.string :difficulty
|
|
10
10
|
t.boolean :active, default: true
|
|
11
11
|
t.references :user, limit: 8, foreign_key: true, index: true, null: true
|
|
12
|
-
t.references :root_account, foreign_key: { to_table: 'accounts'}, limit: 8, null: false, index: true
|
|
13
12
|
|
|
14
13
|
t.timestamps
|
|
15
14
|
end
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
### QALAM_MERIT ###
|
|
2
2
|
class Merit::Badge < ActiveRecord::Base
|
|
3
|
+
# include Workflow
|
|
4
|
+
# include Context
|
|
3
5
|
self.table_name = "merit_badges"
|
|
6
|
+
@valid_images = ["image/jpeg", "image/png", "image/bmp", "image/jpg"]
|
|
4
7
|
|
|
5
8
|
before_validation :strip_whitespace
|
|
6
9
|
def strip_whitespace
|
|
@@ -8,19 +11,27 @@ class Merit::Badge < ActiveRecord::Base
|
|
|
8
11
|
self.description = self.description.strip unless self.description.nil?
|
|
9
12
|
end
|
|
10
13
|
|
|
11
|
-
validates :
|
|
12
|
-
validates :name, presence: true, length: { minimum: 3, maximum: 10 }
|
|
14
|
+
validates :name, presence: true, length: { minimum: 3, maximum: 20 }
|
|
13
15
|
validates :points, presence: true, numericality: true, :inclusion => 1..100
|
|
14
|
-
validates :description, presence:
|
|
16
|
+
validates :description, presence: true, length: { minimum: 3, maximum: 50 }
|
|
15
17
|
|
|
16
18
|
has_one :image, :class_name => 'Attachment', :as => :context, :inverse_of => :context, :dependent => :destroy
|
|
17
|
-
belongs_to :root_account, foreign_key: "root_account_id", class_name: 'Account'
|
|
18
19
|
belongs_to :created_by, foreign_key: "user_id", class_name: 'User'
|
|
19
|
-
has_many :badges_sashes, class_name: 'Merit::QalamBadgeSash'
|
|
20
|
-
has_many :sashes, through: :badges_sashes, source: :sash
|
|
21
20
|
|
|
22
21
|
def image_url
|
|
23
|
-
|
|
22
|
+
if self.image
|
|
23
|
+
return self.image.public_url
|
|
24
|
+
else
|
|
25
|
+
return '/images/apple-touch-icon.png'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.valid_images
|
|
30
|
+
@valid_images
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def badges_sashes
|
|
34
|
+
Merit::BadgesSash.where(badge_id: self.id)
|
|
24
35
|
end
|
|
25
36
|
|
|
26
37
|
class << self
|
|
@@ -47,9 +58,6 @@ class Merit::Badge < ActiveRecord::Base
|
|
|
47
58
|
badge
|
|
48
59
|
end
|
|
49
60
|
|
|
50
|
-
# Defines Badge#meritable_models method, to get related
|
|
51
|
-
# entries with certain badge. For instance, Badge.find(3).users
|
|
52
|
-
# orm-specified
|
|
53
61
|
def _define_related_entries_method(meritable_class_name)
|
|
54
62
|
define_method(:"#{meritable_class_name.underscore.pluralize}") do
|
|
55
63
|
sashes = Merit::QalamBadgeSash.where(badge_id: id).pluck(:sash_id)
|
|
@@ -58,11 +66,19 @@ class Merit::Badge < ActiveRecord::Base
|
|
|
58
66
|
end
|
|
59
67
|
|
|
60
68
|
def create_with_attachment(account, badge, attachment)
|
|
61
|
-
account.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
return true if ((attachment.nil? || attachment.to_s == "null") || account.nil? || badge.nil?)
|
|
70
|
+
if attachment.content_type && @valid_images.include?(attachment.content_type)
|
|
71
|
+
account.shard.activate do
|
|
72
|
+
att = Attachment.create_data_attachment(badge, attachment)
|
|
73
|
+
badge.image = att
|
|
74
|
+
badge.save!
|
|
75
|
+
badge
|
|
76
|
+
end
|
|
77
|
+
return true
|
|
78
|
+
else
|
|
79
|
+
badge.errors.add(:image, :invalid_format, message: 'invalid image format')
|
|
80
|
+
badge.destroy if badge.id
|
|
81
|
+
return false
|
|
66
82
|
end
|
|
67
83
|
end
|
|
68
84
|
end
|
data/qalam_merit.gemspec
CHANGED
|
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
|
|
|
6
6
|
s.files = `git ls-files`.split("\n").reject{|f| f =~ /^\./ }
|
|
7
7
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
|
8
8
|
s.license = 'MIT'
|
|
9
|
-
s.version = '4.5.
|
|
9
|
+
s.version = '4.5.08'
|
|
10
10
|
s.authors = ["Tute Costa", "Ahmed Abdelhamid"]
|
|
11
11
|
s.email = ['tutecosta@gmail.com', 'a.hamid@nezam.io']
|
|
12
12
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: qalam_merit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.5.
|
|
4
|
+
version: 4.5.08
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tute Costa
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2021-03-
|
|
12
|
+
date: 2021-03-07 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: zeitwerk
|