gaku_api 0.3.0.pre.4 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2022049a291ae30871d7cb99cd7e634c4793337a99da7b223b88247cc12da3a4
4
- data.tar.gz: 539d9b8910f2ae44c1c315bb77121170bdb5940f664d3a7a0a60c5fc2ac8ab80
3
+ metadata.gz: 5ea10622d24546466a1c46120b63f984d893a851573ac7d2ce5e76ea6b469542
4
+ data.tar.gz: 2ad0cdc8046728259ade520dcb9c1ba0cc5e669b72062df7110c918fc2c7ce1d
5
5
  SHA512:
6
- metadata.gz: d705d970e7707a30c5ac0ed92f9bcec973fff85c7a5bc01fa1cbb2efa2d6e105db378f28266643ddb4936bf64aaadfe7facf8a80159effab92b182b5bca0ddba
7
- data.tar.gz: b8487fb3e71bc6467425a4fc9e32230cf1ba182bbfeca0a5450fbc034c05aaa61f43e289af118ab5e15c3fe31dddba1ca90c0bab170a4ff0b6ab241afa32c483
6
+ metadata.gz: f67a80667f4cd233d0a3f38ffed255d552a663de91b01c2988a0d8d7b7c9aaba42f5e14d2ad878564a6065502bd26ea5ce03136464e7da42aff3e14adf562b91
7
+ data.tar.gz: ea398b05187e36a8ac49b8e7d938b0978a68d7f43ad08b62e06f0a59047bf3e22c60ee4b4ad993e8ce4b4009b519b9ec45ebff905eed30d18b9f139ebd0f3f8d
@@ -5,9 +5,9 @@ class Gaku::Api::V1::BaseController < Gaku::Api::ApplicationController
5
5
  before_action :set_default_format
6
6
  before_action :authenticate_request
7
7
 
8
- # rescue_from StandardError do |exception|
9
- # render respond_format => { error: exception.message }, status: 500
10
- # end
8
+ rescue_from StandardError do |exception|
9
+ render respond_format => { error: exception.message }, status: 500
10
+ end
11
11
 
12
12
  # rescue_from ActiveRecord::RecordNotFound, with: :render_not_found_response
13
13
  # rescue_from ActiveRecord::RecordInvalid, with: :render_unprocessable_entity_response
@@ -28,7 +28,7 @@ class Gaku::Api::V1::BaseController < Gaku::Api::ApplicationController
28
28
  end
29
29
 
30
30
  def meta_for(collection)
31
- { count: collection.size , total_count: collection.total_count, page: collection.current_page }
31
+ { count: collection.size }
32
32
  end
33
33
 
34
34
  def authenticate_request
@@ -0,0 +1,27 @@
1
+ module Gaku
2
+ module Api
3
+ module V1
4
+ class ContactTypesController < BaseController
5
+ skip_before_action :authenticate_request
6
+
7
+ def index
8
+ @contact_types = ContactType.all
9
+ collection_respond_to @contact_types, root: :contact_types
10
+ end
11
+
12
+ def create
13
+ @contact_types = ContactType.create!(contact_type_params)
14
+ member_respond_to @contact_types
15
+ end
16
+
17
+ private
18
+
19
+ def contact_type_params
20
+ params.require(:name)
21
+ params.permit(:name)
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,41 @@
1
+ module Gaku
2
+ module Api
3
+ module V1
4
+ class ContactsController < BaseController
5
+ skip_before_action :authenticate_request
6
+ before_action :set_contactable
7
+
8
+
9
+ def index
10
+ @contacts = @contactable.contacts.all
11
+ collection_respond_to @contacts, root: :contacts
12
+ end
13
+
14
+ def create
15
+ @contact = @contactable.contacts.create(contact_params)
16
+ member_respond_to @contact
17
+ end
18
+
19
+ private
20
+
21
+ def contact_params
22
+ params.require(contact_attributes)
23
+ params.permit(contact_attributes)
24
+ end
25
+
26
+
27
+ def contact_attributes
28
+ %i( contact_type_id data )
29
+ end
30
+
31
+
32
+ def set_contactable
33
+ model_name = params[:model_name]
34
+ @contactable = model_name.constantize.find(params[model_name.foreign_key])
35
+ end
36
+
37
+
38
+ end
39
+ end
40
+ end
41
+ end
@@ -7,11 +7,14 @@ module Gaku
7
7
  before_action :set_student, except: %i( index create )
8
8
 
9
9
  def index
10
- @q = Student.includes(:primary_contact, :primary_address).search(params[:q])
11
- @students = @q.result.page(params[:page])
10
+ @students = Student.includes(:primary_contact, :primary_address).all
12
11
  collection_respond_to @students, root: :students
13
12
  end
14
13
 
14
+ def picture
15
+ send_file @student.picture.path
16
+ end
17
+
15
18
  def show
16
19
  member_respond_to @student
17
20
  end
@@ -56,8 +59,8 @@ module Gaku
56
59
 
57
60
  def student_attributes
58
61
  %i(
59
- name surname name_reading surname_reading birth_date gender scholarship_status_id,
60
- enrollment_status_code commute_method_type_id admitted graduated picture
62
+ name surname name_reading surname_reading middle_name middle_name_reading
63
+ birth_date gender enrollment_status_code picture
61
64
  )
62
65
  end
63
66
 
@@ -0,0 +1,14 @@
1
+ module Gaku
2
+ class ContactSerializer < ActiveModel::Serializer
3
+ attributes %i( id data contact_type_id )
4
+ attribute :student_id, if: :student_contact?
5
+
6
+ def student_id
7
+ object.contactable_id
8
+ end
9
+
10
+ def student_contact?
11
+ object.contactable_type == 'Gaku::Student'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ module Gaku
2
+ class ContactTypeSerializer < ActiveModel::Serializer
3
+ attributes %i( id name )
4
+ end
5
+ end
@@ -6,13 +6,16 @@ Gaku::Core::Engine.routes.draw do
6
6
  post 'authenticate', to: 'authentication#authenticate'
7
7
  post 'authenticate/refresh', to: 'authentication#refresh'
8
8
 
9
- resources :students do
9
+ resources :students, model_name: 'Gaku::Student' do
10
10
  resources :guardians, controller: 'students/guardians'
11
11
  resources :student_guardians, controller: 'students/student_guardians', only: %i(create destroy)
12
12
  resources :courses, controller: 'students/courses'
13
13
  resources :class_groups, controller: 'students/class_groups'
14
14
  resources :extracurricular_activities, controller: 'students/extracurricular_activities'
15
15
  resources :exam_sessions, controller: 'students/exam_sessions'
16
+ resources :contacts
17
+
18
+ get :picture, on: :member
16
19
  end
17
20
 
18
21
  resources :courses do
@@ -26,6 +29,7 @@ Gaku::Core::Engine.routes.draw do
26
29
  end
27
30
 
28
31
  resources :syllabuses
32
+ resources :contact_types
29
33
  end
30
34
  end
31
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gaku_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rei Kagetsuki
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-02-26 00:00:00.000000000 Z
13
+ date: 2018-03-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: simple_command
@@ -88,28 +88,28 @@ dependencies:
88
88
  requirements:
89
89
  - - '='
90
90
  - !ruby/object:Gem::Version
91
- version: 0.3.0.pre.4
91
+ version: 0.3.0
92
92
  type: :runtime
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - '='
97
97
  - !ruby/object:Gem::Version
98
- version: 0.3.0.pre.4
98
+ version: 0.3.0
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: gaku_testing
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
103
  - - '='
104
104
  - !ruby/object:Gem::Version
105
- version: 0.3.0.pre.4
105
+ version: 0.3.0
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - '='
111
111
  - !ruby/object:Gem::Version
112
- version: 0.3.0.pre.4
112
+ version: 0.3.0
113
113
  description: API functionality for GAKU Engine. See https://github.com/GAKUEngine/gaku
114
114
  email: info@gakuengine.com
115
115
  executables: []
@@ -122,6 +122,8 @@ files:
122
122
  - app/controllers/gaku/api/v1/base_controller.rb
123
123
  - app/controllers/gaku/api/v1/class_groups/enrollments_controller.rb
124
124
  - app/controllers/gaku/api/v1/class_groups/students_controller.rb
125
+ - app/controllers/gaku/api/v1/contact_types_controller.rb
126
+ - app/controllers/gaku/api/v1/contacts_controller.rb
125
127
  - app/controllers/gaku/api/v1/courses/enrollments_controller.rb
126
128
  - app/controllers/gaku/api/v1/courses/students_controller.rb
127
129
  - app/controllers/gaku/api/v1/courses_controller.rb
@@ -136,6 +138,8 @@ files:
136
138
  - app/controllers/gaku/api/v1/students_controller.rb
137
139
  - app/controllers/gaku/api/v1/syllabuses_controller.rb
138
140
  - app/serializers/gaku/class_group_serializer.rb
141
+ - app/serializers/gaku/contact_serializer.rb
142
+ - app/serializers/gaku/contact_type_serializer.rb
139
143
  - app/serializers/gaku/course_serializer.rb
140
144
  - app/serializers/gaku/enrollment_serializer.rb
141
145
  - app/serializers/gaku/exam_session_serializer.rb
@@ -172,9 +176,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
176
  version: '0'
173
177
  required_rubygems_version: !ruby/object:Gem::Requirement
174
178
  requirements:
175
- - - ">"
179
+ - - ">="
176
180
  - !ruby/object:Gem::Version
177
- version: 1.3.1
181
+ version: '0'
178
182
  requirements: []
179
183
  rubyforge_project:
180
184
  rubygems_version: 2.7.3