qalam_merit 4.5.08 → 4.5.09

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: 3d1f73f153930fdd73e1ba773d40feb481ab847a7d6857623779de05eacb8817
4
- data.tar.gz: 62ddf64eecbb98665f47c841476fc1d5045813ff97db1bcf9c8fe8347c026f57
3
+ metadata.gz: 54fd36c8d0594e5288774e2caf5b4bca4b642e63fefd50d564b80ce5abdbaae0
4
+ data.tar.gz: 7bf97cb6b288354c70bf82f2573d37db6b363230309243848ed7335240282e30
5
5
  SHA512:
6
- metadata.gz: 8e1b99abd43904c894b2e75d590c0d901ab090a24a5f5d83fdd16af6c0307301a74ee93752e5c30f52a3281e763bb8132bb0a4ae14195ec546b29613c3cb6cb5
7
- data.tar.gz: e976e63ad65c74580397199ea05e8f413a17a51834226066774b83c24517f8feb62cff128be39bb1e6c7e3ceccb338f15d21bfcd1e6121bc38ca94e183abb292
6
+ metadata.gz: 0ecdd00a696088ac97a9ed78671f3c3f8a98da81a89d1d722306c4b6c46cd86f3cc8c9262eb09408afaee973a62891ead6f2260b0b2de775c3eacef09c8ea3f8
7
+ data.tar.gz: f04638fd6694a4f0af6aae82d5db77b30263d494f3267530247b161a31f07454275cf6abfa994b783c40ee58370cb0b7f90a691ee4f61981168ae9af937b0b85
@@ -16,7 +16,7 @@ module Merit
16
16
 
17
17
  # Delegate methods from meritable models to their sash
18
18
  def _merit_delegate_methods_to_sash
19
- methods = %w(badge_ids badges points add_badge add_qalam_badge rm_badge
19
+ methods = %w(badge_ids badges points add_badge rm_badge
20
20
  add_points subtract_points score_points)
21
21
  methods.each { |method| delegate method, to: :_sash }
22
22
  end
@@ -11,9 +11,9 @@ class Merit::Badge < ActiveRecord::Base
11
11
  self.description = self.description.strip unless self.description.nil?
12
12
  end
13
13
 
14
- validates :name, presence: true, length: { minimum: 3, maximum: 20 }
14
+ validates :name, presence: true, length: { minimum: 1, maximum: 20 }
15
15
  validates :points, presence: true, numericality: true, :inclusion => 1..100
16
- validates :description, presence: true, length: { minimum: 3, maximum: 50 }
16
+ validates :description, presence: true, length: { minimum: 3, maximum: 100 }
17
17
 
18
18
  has_one :image, :class_name => 'Attachment', :as => :context, :inverse_of => :context, :dependent => :destroy
19
19
  belongs_to :created_by, foreign_key: "user_id", class_name: 'User'
@@ -66,7 +66,12 @@ class Merit::Badge < ActiveRecord::Base
66
66
  end
67
67
 
68
68
  def create_with_attachment(account, badge, attachment)
69
- return true if ((attachment.nil? || attachment.to_s == "null") || account.nil? || badge.nil?)
69
+ if ((attachment.nil? || attachment.to_s == "null") || account.nil? || badge.nil?)
70
+ badge.errors.add(:image, :image_required, message: 'Image Required')
71
+ badge.destroy if badge.id
72
+ return false
73
+ end
74
+
70
75
  if attachment.content_type && @valid_images.include?(attachment.content_type)
71
76
  account.shard.activate do
72
77
  att = Attachment.create_data_attachment(badge, attachment)
@@ -26,13 +26,6 @@ module Merit::Models
26
26
  end
27
27
  end
28
28
 
29
- ########################QALAM_DEV#########################
30
- def add_qalam_badge(badge_id, course_id)
31
- bs = Merit::BadgesSash.new(badge_id: badge_id.to_i, course_id: course_id.to_i)
32
- badges_sashes << bs
33
- bs
34
- end
35
- ########################END###################################
36
29
  # Retrieve the number of points from a category
37
30
  # By default all points are summed up
38
31
  # @param category [String] The category
@@ -48,10 +41,11 @@ module Merit::Models
48
41
  def add_points(num_points, options = {})
49
42
  point = Merit::QalamScore::Point.new
50
43
  point.num_points = num_points
44
+ point.course_id = options[:course_id].to_i
51
45
  scores
52
- .where(category: options[:category] || 'default')
53
- .first_or_create
54
- .score_points << point
46
+ .where(category: options[:category] || 'default')
47
+ .first_or_create
48
+ .score_points << point
55
49
  point
56
50
  end
57
51
 
data/qalam_merit.gemspec CHANGED
@@ -6,9 +6,9 @@ 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.08'
10
- s.authors = ["Tute Costa", "Ahmed Abdelhamid"]
11
- s.email = ['tutecosta@gmail.com', 'a.hamid@nezam.io']
9
+ s.version = '4.5.09'
10
+ s.authors = ["Ahmed Abdelhamid", "Zeyad Saleh"]
11
+ s.email = ['a.hamid@nezam.io', 'zeyad.saleh@nezam.io']
12
12
 
13
13
  s.required_ruby_version = '>= 2.3.0'
14
14
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qalam_merit
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.08
4
+ version: 4.5.09
5
5
  platform: ruby
6
6
  authors:
7
- - Tute Costa
8
7
  - Ahmed Abdelhamid
8
+ - Zeyad Saleh
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-07 00:00:00.000000000 Z
12
+ date: 2021-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: zeitwerk
@@ -111,8 +111,8 @@ dependencies:
111
111
  version: '0'
112
112
  description: Manage badges, points and rankings (reputation) in your Rails app.
113
113
  email:
114
- - tutecosta@gmail.com
115
114
  - a.hamid@nezam.io
115
+ - zeyad.saleh@nezam.io
116
116
  executables: []
117
117
  extensions: []
118
118
  extra_rdoc_files: []