Skip to content
This repository was archived by the owner on Jun 16, 2021. It is now read-only.

Commit dbb1361

Browse files
authored
Merge pull request #888 from omu/develop
Merge develop into master
2 parents 9735958 + 7843257 commit dbb1361

File tree

77 files changed

+1208
-913
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1208
-913
lines changed

.markdownlintrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"style": "sublist"
88
},
99
"MD013": {
10-
"code_blocks": false,
11-
"tables": false,
10+
"line_length": 120,
11+
"tables": false
1212
},
1313
"MD024": {
1414
"allow_different_nesting": true

Gemfile

+8-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ gem 'aws-sdk-s3', require: false
2626
gem 'image_processing', '~> 1.2'
2727

2828
# authentication
29+
gem 'authy'
2930
gem 'devise'
3031

3132
# assets: core asset dependencies
@@ -58,10 +59,16 @@ gem 'telephone_number'
5859

5960
# error tracking
6061
gem 'rollbar', github: 'rollbar/rollbar-gem'
62+
gem 'slack-notifier'
6163

6264
# permalinks
6365
gem 'friendly_id', '~> 5.2.0'
6466

67+
# sms
68+
gem 'nexmo'
69+
gem 'smstools'
70+
gem 'twilio-ruby', '~> 5.21.2'
71+
6572
group :development, :test do
6673
gem 'brakeman', require: false
6774
gem 'bullet', github: 'flyerhzm/bullet'
@@ -76,9 +83,8 @@ end
7683

7784
group :test do
7885
gem 'capybara', '>= 2.15'
79-
gem 'chromedriver-helper'
8086
gem 'codacy-coverage', require: false
81-
gem 'selenium-webdriver'
87+
gem 'webdrivers', '~> 3.0'
8288
gem 'webmock'
8389
end
8490

Gemfile.lock

+32-13
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GIT
88

99
GIT
1010
remote: https://github.com/rails/rails.git
11-
revision: efb706daad0e2e1039c6abb4879c837ef8bf4d10
11+
revision: 4ec486145290efb4059b64e84a2bfd9e157bf787
1212
specs:
1313
actioncable (6.0.0.beta3)
1414
actionpack (= 6.0.0.beta3)
@@ -63,7 +63,7 @@ GIT
6363
i18n (>= 0.7, < 2)
6464
minitest (~> 5.1)
6565
tzinfo (~> 1.1)
66-
zeitwerk (~> 1.4)
66+
zeitwerk (~> 1.4, >= 1.4.2)
6767
rails (6.0.0.beta3)
6868
actioncable (= 6.0.0.beta3)
6969
actionmailbox (= 6.0.0.beta3)
@@ -129,11 +129,11 @@ GEM
129129
public_suffix (>= 2.0.2, < 4.0)
130130
ancestry (3.0.5)
131131
activerecord (>= 3.2.0)
132-
archive-zip (0.12.0)
133-
io-like (~> 0.3.0)
134132
ast (2.4.0)
133+
authy (2.7.5)
134+
httpclient (>= 2.5.3.3)
135135
aws-eventstream (1.0.2)
136-
aws-partitions (1.145.0)
136+
aws-partitions (1.146.0)
137137
aws-sdk-core (3.48.2)
138138
aws-eventstream (~> 1.0, >= 1.0.2)
139139
aws-partitions (~> 1.0)
@@ -142,7 +142,7 @@ GEM
142142
aws-sdk-kms (1.16.0)
143143
aws-sdk-core (~> 3, >= 3.48.2)
144144
aws-sigv4 (~> 1.1)
145-
aws-sdk-s3 (1.34.0)
145+
aws-sdk-s3 (1.35.0)
146146
aws-sdk-core (~> 3, >= 3.48.2)
147147
aws-sdk-kms (~> 1)
148148
aws-sigv4 (~> 1.0)
@@ -177,9 +177,6 @@ GEM
177177
chartkick (3.0.2)
178178
childprocess (0.9.0)
179179
ffi (~> 1.0, >= 1.0.11)
180-
chromedriver-helper (2.1.0)
181-
archive-zip (~> 0.10)
182-
nokogiri (~> 1.8)
183180
cocoon (1.2.12)
184181
codacy-coverage (2.1.0)
185182
simplecov
@@ -219,6 +216,8 @@ GEM
219216
smart_properties
220217
erubi (1.8.0)
221218
execjs (2.7.0)
219+
faraday (0.15.4)
220+
multipart-post (>= 1.2, < 3)
222221
ffi (1.10.0)
223222
fit-commit (3.8.1)
224223
swearjar (~> 1.3)
@@ -232,18 +231,19 @@ GEM
232231
activesupport (>= 4.2)
233232
hashdiff (0.3.8)
234233
html_tokenizer (0.0.7)
234+
httpclient (2.8.3)
235235
i18n (1.6.0)
236236
concurrent-ruby (~> 1.0)
237237
image_processing (1.8.0)
238238
mini_magick (>= 4.9.3, < 5)
239239
ruby-vips (>= 2.0.13, < 3)
240-
io-like (0.3.0)
241240
jaro_winkler (1.5.2)
242241
jbuilder (2.8.0)
243242
activesupport (>= 4.2.0)
244243
multi_json (>= 1.2)
245244
jmespath (1.4.0)
246245
json (2.2.0)
246+
jwt (2.1.0)
247247
launchy (2.4.3)
248248
addressable (~> 2.3)
249249
letter_opener (1.7.0)
@@ -271,7 +271,11 @@ GEM
271271
minitest (5.11.3)
272272
msgpack (1.2.9)
273273
multi_json (1.13.1)
274+
multipart-post (2.0.0)
275+
net_http_ssl_fix (0.0.10)
274276
netaddr (2.0.3)
277+
nexmo (5.6.0)
278+
jwt (~> 2)
275279
nio4r (2.3.1)
276280
nokogiri (1.10.1)
277281
mini_portile2 (~> 2.4.0)
@@ -365,7 +369,9 @@ GEM
365369
simplecov-html (0.10.2)
366370
simpleidn (0.1.1)
367371
unf (~> 0.1.4)
372+
slack-notifier (2.3.2)
368373
smart_properties (1.13.1)
374+
smstools (0.2.0)
369375
spring (2.0.2)
370376
activesupport (>= 4.2)
371377
spring-watcher-listen (2.0.1)
@@ -383,6 +389,10 @@ GEM
383389
thor (0.20.3)
384390
thread_safe (0.3.6)
385391
tilt (2.0.9)
392+
twilio-ruby (5.21.2)
393+
faraday (~> 0.9)
394+
jwt (>= 1.5, <= 2.5)
395+
nokogiri (>= 1.6, < 2.0)
386396
tzinfo (1.2.5)
387397
thread_safe (~> 0.1)
388398
uglifier (4.1.20)
@@ -394,6 +404,11 @@ GEM
394404
uniform_notifier (1.12.1)
395405
warden (1.2.8)
396406
rack (>= 2.0.6)
407+
webdrivers (3.7.0)
408+
net_http_ssl_fix
409+
nokogiri (~> 1.6)
410+
rubyzip (~> 1.0)
411+
selenium-webdriver (~> 3.0)
397412
webmock (3.5.1)
398413
addressable (>= 2.3.6)
399414
crack (>= 0.3.2)
@@ -409,13 +424,14 @@ GEM
409424
activesupport
410425
xpath (3.2.0)
411426
nokogiri (~> 1.8)
412-
zeitwerk (1.4.0)
427+
zeitwerk (1.4.2)
413428

414429
PLATFORMS
415430
ruby
416431

417432
DEPENDENCIES
418433
ancestry
434+
authy
419435
aws-sdk-s3
420436
bcrypt (~> 3.1.7)
421437
bootsnap (>= 1.4.0)
@@ -425,7 +441,6 @@ DEPENDENCIES
425441
byebug
426442
capybara (>= 2.15)
427443
chartkick
428-
chromedriver-helper
429444
cocoon
430445
codacy-coverage
431446
coffee-rails (~> 4.2)
@@ -442,6 +457,7 @@ DEPENDENCIES
442457
letter_opener
443458
listen (>= 3.0.5, < 3.2)
444459
lol_dba
460+
nexmo
445461
nokul-support!
446462
nokul-tenant!
447463
nokul-tenant-omu!
@@ -461,15 +477,18 @@ DEPENDENCIES
461477
rubocop
462478
ruby-progressbar
463479
sassc-rails
464-
selenium-webdriver
465480
sidekiq
466481
simple_form
467482
simplecov
483+
slack-notifier
484+
smstools
468485
spring
469486
spring-watcher-listen (~> 2.0.0)
470487
telephone_number
488+
twilio-ruby (~> 5.21.2)
471489
uglifier (>= 1.3.0)
472490
web-console!
491+
webdrivers (~> 3.0)
473492
webmock
474493
webpacker
475494
wicked_pdf

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
[![Security](https://hakiri.io/projects/cf546402fb7117/stacks/622121c74c17f4/622121c74c17f4.svg?repo_token=xo-yGdqDKXvCf-jypXd-)](https://hakiri.io/projects/cf546402fb7117/stacks/622121c74c17f4/shield)
99
[![Known Vulnerabilities](https://snyk.io/test/github/omu/nokul/badge.svg)](https://snyk.io/test/github/omu/nokul)
1010

11-
1211
[Nokul](https://github.com/omu/nokul) aims to become a complete solution for universities that face many challanges while trying to manage all the complex procedures of a university online.
1312

1413
Dealing with ill-structured processes of a university is hard, especially when they backed with complex legal procedures. Many universities facing similar issues when it comes to automating things, and moving face-to-face operations to online. Nokul aims to remediate these wounds by taking a Turkish university with more than 70 web services, 50K students and 4K employees as a case.

app/controllers/calendar_management/calendars_controller.rb

+5-6
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,13 @@ def destroy
4343
end
4444

4545
def duplicate
46-
@calendar = Calendar.find(params[:calendar_id])
47-
@duplicate_record = DuplicateService.new(@calendar, 'name').duplicate
48-
49-
redirect_to(:calendars, alert: t('.warning')) && return unless @duplicate_record
46+
calendar = Calendar.find(params[:calendar_id])
5047

51-
AcademicCalendars::DuplicateEventsService.new(@calendar, @duplicate_record)
48+
duplicate_record = AcademicCalendars::DuplicateCalendarService.new(calendar, 'name').duplicate
49+
redirect_to(:calendars, alert: t('.warning')) && return unless duplicate_record
5250

53-
redirect_to([:edit, @duplicate_record], notice: t('.success'))
51+
AcademicCalendars::DuplicateEventsService.new(calendar, duplicate_record)
52+
redirect_to([:edit, duplicate_record], notice: t('.success'))
5453
end
5554

5655
def units

app/errors/concatenation_error.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
class ConcatenationError < StandardError
4+
def message
5+
I18n.t('errors.can_not_be_concatenated')
6+
end
7+
end

app/errors/encoding_mismatch_error.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
class EncodingMismatchError < StandardError
4+
def message
5+
I18n.t('errors.encoding_mismatch')
6+
end
7+
end

app/errors/id_number_error.rb

-7
This file was deleted.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
class InvalidPhoneNumberError < StandardError
4+
def message
5+
I18n.t('errors.invalid_phone_number')
6+
end
7+
end

app/errors/unicode_support_error.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
class UnicodeSupportError < StandardError
4+
def message
5+
I18n.t('errors.unicode_not_supported')
6+
end
7+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# frozen_string_literal: true
2+
3+
module AcademicCalendars
4+
class DuplicateCalendarService
5+
attr_reader :record, :prefixed_param
6+
7+
def initialize(record, prefixed_param)
8+
@record = record
9+
@prefixed_param = prefixed_param
10+
end
11+
12+
def duplicate
13+
clone_record = @record.dup
14+
clone_record.send(@prefixed_param).prepend('[Kopyası] ')
15+
clone_record.committee_decisions << @record.committee_decisions
16+
clone_record.save
17+
clone_record
18+
end
19+
end
20+
end

app/services/duplicate_service.rb

-17
This file was deleted.

app/services/nexmo/error_handler.rb

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# frozen_string_literal: true
2+
3+
module Nexmo
4+
module ErrorHandler
5+
SOFT_FAIL_CODES = {
6+
'2' => 'Missing Parameters',
7+
'3' => 'Invalid Parameters',
8+
'6' => 'Invalid Message',
9+
'12' => 'Message Too Long',
10+
'22' => 'Invalid Network Code',
11+
'33' => 'Number De-activated'
12+
}.freeze
13+
14+
HARD_FAIL_CODES = {
15+
'1' => 'Throttled',
16+
'4' => 'Invalid Credentials',
17+
'5' => 'Internal Error',
18+
'7' => 'Number Barred',
19+
'8' => 'Partner Account Barred',
20+
'9' => 'Partner Quota Violation',
21+
'10' => 'Too Many Existing Binds',
22+
'11' => 'Account Not Enabled For HTTP',
23+
'14' => 'Invalid Signature',
24+
'15' => 'Invalid Sender Address',
25+
'23' => 'Invalid Callback Url',
26+
'32' => 'Signature And API Secret Disallowed'
27+
}.freeze
28+
29+
def log_or_notify_admin(response)
30+
status = response.status
31+
notifier = Slack::Notifier.new Tenant.credentials.slack[:panik_hook]
32+
33+
if status == '0'
34+
Rails.logger.info "Sent message id=#{response.message_id}"
35+
elsif SOFT_FAIL_CODES.key?(status) || HARD_FAIL_CODES.key?(status)
36+
notifier.ping "Nexmo SMS Error (code: #{status}, text: #{response.error_text})"
37+
end
38+
end
39+
end
40+
end

0 commit comments

Comments
 (0)