nippo_core 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -3
  3. data/app/assets/javascripts/nippo_core/application.js +3 -0
  4. data/app/assets/stylesheets/nippo_core/config.sass +697 -0
  5. data/app/assets/stylesheets/nippo_core/style.sass +0 -0
  6. data/app/controllers/nippo_core/application_controller.rb +6 -0
  7. data/app/controllers/nippo_core/group_member_relations_controller.rb +18 -0
  8. data/app/controllers/nippo_core/groups_controller.rb +10 -1
  9. data/app/controllers/nippo_core/home_controller.rb +2 -0
  10. data/app/controllers/nippo_core/reports_controller.rb +7 -6
  11. data/app/controllers/nippo_core/users_controller.rb +10 -0
  12. data/app/decorators/nippo_core/user_decorator.rb +7 -0
  13. data/app/models/nippo_core/group.rb +12 -0
  14. data/app/models/nippo_core/group_member_relation.rb +10 -0
  15. data/app/models/nippo_core/user.rb +2 -0
  16. data/app/policies/application_policy.rb +53 -0
  17. data/app/policies/nippo_core/report_policy.rb +27 -0
  18. data/app/views/layouts/nippo_core/application.slim +17 -1
  19. data/app/views/nippo_core/group_member_relations/new.slim +4 -0
  20. data/app/views/nippo_core/groups/index.slim +12 -0
  21. data/app/views/nippo_core/groups/show.slim +20 -0
  22. data/app/views/nippo_core/home/index.slim +13 -2
  23. data/app/views/nippo_core/reports/index.slim +1 -0
  24. data/app/views/nippo_core/users/show.slim +32 -0
  25. data/config/locales/devise.ja.yml +4 -0
  26. data/config/locales/ja.yml +17 -0
  27. data/config/routes.rb +4 -1
  28. data/db/migrate/20170420155712_create_nippo_core_group_member_relations.rb +14 -0
  29. data/lib/nippo_core/engine.rb +2 -0
  30. data/lib/nippo_core/version.rb +1 -1
  31. metadata +53 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0aa1b3448f7789130ad93f6ac442789127212ad
4
- data.tar.gz: 6fbf71e01497eb263b368f55a6bdc4728dba0ae1
3
+ metadata.gz: 8377e6389fa4c8f4a6bf7f2671cf80a46b78c0fb
4
+ data.tar.gz: 6526438189d1fcd30e4dba596ad7c2ac336e9662
5
5
  SHA512:
6
- metadata.gz: ae01bc7c0e318937bdfdf0f5046b6590633093dcc9c895debeeb5e7adcb046908db40983bccfc9191463a0579d98db67128d3111b3c53384ac4dccd5c1f3ff27
7
- data.tar.gz: c38d24ced09548ef912ae67c74d1a2749fab46ec93bc7c814cf8363f5b1ff3d561764da8017424d8c491c9011e6690b4f308b817c5e9f7b9d0bff2f4eceb760b
6
+ metadata.gz: 117027c5f86fd9e34266fd763fe96dc3afb435f1c1e917cc2765a1bec0ccd9eec9180c6f453fff6a0e04f30e836ecdd7724a776b770d32ef085b33e55693f95d
7
+ data.tar.gz: 00f96001be8c7578d3377a552043b6c219988189672c8fd87686306a3278bc7aff06b695b59fb287f03b11cc3573ca14dc3e8f7b513d5954c8eb2dc14ea39df2
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # NippoCore
2
- 日報システム **(製作中)**
2
+ This is a daily report system gem for Rails application.
3
+ Mount this system to yours, you can use daily report sharing system.
3
4
 
4
5
  ## Usage
5
- メインのシステムにマウントしてください
6
6
 
7
7
  ## Installation
8
8
  Add this line to your application's Gemfile:
9
9
 
10
- ```ruby
10
+ ```ruby:Gemfile
11
11
  gem 'nippo_core'
12
12
  ```
13
13
 
@@ -21,6 +21,12 @@ Or install it yourself as:
21
21
  $ gem install nippo_core
22
22
  ```
23
23
 
24
+ Then, mount to main system. In `config/routes.rb`
25
+ ```ruby:config/routes.rb
26
+ # change path where you want to mount
27
+ mount NippoCore::Engine => '/mount_point'
28
+ ```
29
+
24
30
  ## Contributing
25
31
  Contribution directions go here.
26
32
 
@@ -10,4 +10,7 @@
10
10
  // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require turbolinks
13
16
  //= require_tree .
@@ -0,0 +1,697 @@
1
+ /* ** ブラウザのデフォルト設定の打ち消し ** */
2
+
3
+ body, html, h1, h2, h3, h4, h5
4
+ margin: 0
5
+
6
+ ul
7
+ list-style-type: none
8
+ margin: 0
9
+ padding: 0
10
+
11
+ a
12
+ color: #000
13
+ text-decoration: none
14
+
15
+ /* ** コンテナ設定 ** */
16
+
17
+ .container
18
+ width: 100%
19
+ margin: 0 auto
20
+
21
+ @media (min-width: 480px)
22
+ .container
23
+ width: 344px
24
+
25
+ @media (min-width: 768px) and (max-width: 1024px)
26
+ .container
27
+ width: 728px
28
+
29
+ @media (min-width: 1024px)
30
+ .container
31
+ width: 960px
32
+
33
+ .container_with-header-padding
34
+ padding-top: 70px
35
+
36
+ /* ** ヘッダ設定 ** */
37
+
38
+ .header
39
+ width: 100%
40
+ height: 70px
41
+
42
+ .header_fixed
43
+ position: fixed
44
+ top: 0
45
+ left: 0
46
+
47
+ /* ** グリッド ** */
48
+
49
+ .row
50
+ width: 100%
51
+ display: flex
52
+ flex-wrap: wrap
53
+
54
+ .row__col_0
55
+ width: 0
56
+
57
+ .row__col_1
58
+ width: calc(100% / 24)
59
+
60
+ .row__col_2
61
+ width: calc(100% / 12)
62
+
63
+ .row__col_3
64
+ width: 12.5%
65
+
66
+ .row__col_4
67
+ width: calc(100% / 6)
68
+
69
+ .row__col_5
70
+ width: calc(500% / 24)
71
+
72
+ .row__col_6
73
+ width: 25%
74
+
75
+ .row__col_7
76
+ width: calc(700% / 24)
77
+
78
+ .row__col_8
79
+ width: calc(100% / 3)
80
+
81
+ .row__col_9
82
+ width: 37.5%
83
+
84
+ .row__col_10
85
+ width: calc(500% / 12)
86
+
87
+ .row__col_11
88
+ width: calc(1100% / 24)
89
+
90
+ .row__col_12
91
+ width: 50%
92
+
93
+ .row__col_13
94
+ width: calc(1300% / 24)
95
+
96
+ .row__col_14
97
+ width: calc(700% / 12)
98
+
99
+ .row__col_15
100
+ width: 62.5%
101
+
102
+ .row__col_16
103
+ width: calc(200% / 3)
104
+
105
+ .row__col_17
106
+ width: calc(1700% / 24)
107
+
108
+ .row__col_18
109
+ width: 75%
110
+
111
+ .row__col_19
112
+ width: calc(1900% / 24)
113
+
114
+ .row__col_20
115
+ width: calc(500% / 6)
116
+
117
+ .row__col_21
118
+ width: 85%
119
+
120
+ .row__col_22
121
+ width: calc(1100% / 12)
122
+
123
+ .row__col_23
124
+ width: calc(2300% / 24)
125
+
126
+ .row__col_24
127
+ width: 100%
128
+
129
+ @media (min-width: 480px)
130
+ .row__col_0_s
131
+ width: 0
132
+
133
+ .row__col_1_s
134
+ width: calc(100% / 24)
135
+
136
+ .row__col_2_s
137
+ width: calc(100% / 12)
138
+
139
+ .row__col_3_s
140
+ width: 12.5%
141
+
142
+ .row__col_4_s
143
+ width: calc(100% / 6)
144
+
145
+ .row__col_5_s
146
+ width: calc(500% / 24)
147
+
148
+ .row__col_6_s
149
+ width: 25%
150
+
151
+ .row__col_7_s
152
+ width: calc(700% / 24)
153
+
154
+ .row__col_8_s
155
+ width: calc(100% / 3)
156
+
157
+ .row__col_9_s
158
+ width: 37.5%
159
+
160
+ .row__col_10_s
161
+ width: calc(500% / 12)
162
+
163
+ .row__col_11_s
164
+ width: calc(1100% / 24)
165
+
166
+ .row__col_12_s
167
+ width: 50%
168
+
169
+ .row__col_13_s
170
+ width: calc(1300% / 24)
171
+
172
+ .row__col_14_s
173
+ width: calc(700% / 12)
174
+
175
+ .row__col_15_s
176
+ width: 62.5%
177
+
178
+ .row__col_16_s
179
+ width: calc(200% / 3)
180
+
181
+ .row__col_17_s
182
+ width: calc(1700% / 24)
183
+
184
+ .row__col_18_s
185
+ width: 75%
186
+
187
+ .row__col_19_s
188
+ width: calc(1900% / 24)
189
+
190
+ .row__col_20_s
191
+ width: calc(500% / 6)
192
+
193
+ .row__col_21_s
194
+ width: 85%
195
+
196
+ .row__col_22_s
197
+ width: calc(1100% / 12)
198
+
199
+ .row__col_23_s
200
+ width: calc(2300% / 24)
201
+
202
+ .row__col_24_s
203
+ width: 100%
204
+
205
+ @media (min-width: 768px) and (max-width: 1024px)
206
+ .row__col_0_m
207
+ width: 0
208
+
209
+ .row__col_1_m
210
+ width: calc(100% / 24)
211
+
212
+ .row__col_2_m
213
+ width: calc(100% / 12)
214
+
215
+ .row__col_3_m
216
+ width: 12.5%
217
+
218
+ .row__col_4_m
219
+ width: calc(100% / 6)
220
+
221
+ .row__col_5_m
222
+ width: calc(500% / 24)
223
+
224
+ .row__col_6_m
225
+ width: 25%
226
+
227
+ .row__col_7_m
228
+ width: calc(700% / 24)
229
+
230
+ .row__col_8_m
231
+ width: calc(100% / 3)
232
+
233
+ .row__col_9_m
234
+ width: 37.5%
235
+
236
+ .row__col_10_m
237
+ width: calc(500% / 12)
238
+
239
+ .row__col_11_m
240
+ width: calc(1100% / 24)
241
+
242
+ .row__col_12_m
243
+ width: 50%
244
+
245
+ .row__col_13_m
246
+ width: calc(1300% / 24)
247
+
248
+ .row__col_14_m
249
+ width: calc(700% / 12)
250
+
251
+ .row__col_15_m
252
+ width: 62.5%
253
+
254
+ .row__col_16_m
255
+ width: calc(200% / 3)
256
+
257
+ .row__col_17_m
258
+ width: calc(1700% / 24)
259
+
260
+ .row__col_18_m
261
+ width: 75%
262
+
263
+ .row__col_19_m
264
+ width: calc(1900% / 24)
265
+
266
+ .row__col_20_m
267
+ width: calc(500% / 6)
268
+
269
+ .row__col_21_m
270
+ width: 85%
271
+
272
+ .row__col_22_m
273
+ width: calc(1100% / 12)
274
+
275
+ .row__col_23_m
276
+ width: calc(2300% / 24)
277
+
278
+ .row__col_24_m
279
+ width: 100%
280
+
281
+ @media (min-width: 1024px)
282
+ .row__col_0_l
283
+ width: 0
284
+
285
+ .row__col_1_l
286
+ width: calc(100% / 24)
287
+
288
+ .row__col_2_l
289
+ width: calc(100% / 12)
290
+
291
+ .row__col_3_l
292
+ width: 12.5%
293
+
294
+ .row__col_4_l
295
+ width: calc(100% / 6)
296
+
297
+ .row__col_5_l
298
+ width: calc(500% / 24)
299
+
300
+ .row__col_6_l
301
+ width: 25%
302
+
303
+ .row__col_7_l
304
+ width: calc(700% / 24)
305
+
306
+ .row__col_8_l
307
+ width: calc(100% / 3)
308
+
309
+ .row__col_9_l
310
+ width: 37.5%
311
+
312
+ .row__col_10_l
313
+ width: calc(500% / 12)
314
+
315
+ .row__col_11_l
316
+ width: calc(1100% / 24)
317
+
318
+ .row__col_12_l
319
+ width: 50%
320
+
321
+ .row__col_13_l
322
+ width: calc(1300% / 24)
323
+
324
+ .row__col_14_l
325
+ width: calc(700% / 12)
326
+
327
+ .row__col_15_l
328
+ width: 62.5%
329
+
330
+ .row__col_16_l
331
+ width: calc(200% / 3)
332
+
333
+ .row__col_17_l
334
+ width: calc(1700% / 24)
335
+
336
+ .row__col_18_l
337
+ width: 75%
338
+
339
+ .row__col_19_l
340
+ width: calc(1900% / 24)
341
+
342
+ .row__col_20_l
343
+ width: calc(500% / 6)
344
+
345
+ .row__col_21_l
346
+ width: 85%
347
+
348
+ .row__col_22_l
349
+ width: calc(1100% / 12)
350
+
351
+ .row__col_23_l
352
+ width: calc(2300% / 24)
353
+
354
+ .row__col_24_l
355
+ width: 100%
356
+
357
+ .row__col_with-offset_0
358
+ margin-left: 0
359
+
360
+ .row__col_with-offset_1
361
+ margin-left: calc(100% / 24)
362
+
363
+ .row__col_with-offset_2
364
+ margin-left: calc(100% / 12)
365
+
366
+ .row__col_with-offset_3
367
+ margin-left: 12.5%
368
+
369
+ .row__col_with-offset_4
370
+ margin-left: calc(100% / 6)
371
+
372
+ .row__col_with-offset_5
373
+ margin-left: calc(500% / 24)
374
+
375
+ .row__col_with-offset_6
376
+ margin-left: 25%
377
+
378
+ .row__col_with-offset_7
379
+ margin-left: calc(700% / 24)
380
+
381
+ .row__col_with-offset_8
382
+ margin-left: calc(100% / 3)
383
+
384
+ .row__col_with-offset_9
385
+ margin-left: 37.5%
386
+
387
+ .row__col_with-offset_10
388
+ margin-left: calc(500% / 12)
389
+
390
+ .row__col_with-offset_11
391
+ margin-left: calc(1100% / 24)
392
+
393
+ .row__col_with-offset_12
394
+ margin-left: 50%
395
+
396
+ .row__col_with-offset_13
397
+ margin-left: calc(1300% / 24)
398
+
399
+ .row__col_with-offset_14
400
+ margin-left: calc(700% / 12)
401
+
402
+ .row__col_with-offset_15
403
+ margin-left: 62.5%
404
+
405
+ .row__col_with-offset_16
406
+ margin-left: calc(200% / 3)
407
+
408
+ .row__col_with-offset_17
409
+ margin-left: calc(1700% / 24)
410
+
411
+ .row__col_with-offset_18
412
+ margin-left: 75%
413
+
414
+ .row__col_with-offset_19
415
+ margin-left: calc(1900% / 24)
416
+
417
+ .row__col_with-offset_20
418
+ margin-left: calc(500% / 6)
419
+
420
+ .row__col_with-offset_21
421
+ margin-left: 85%
422
+
423
+ .row__col_with-offset_22
424
+ margin-left: calc(1100% / 12)
425
+
426
+ .row__col_with-offset_23
427
+ margin-left: calc(2300% / 24)
428
+
429
+ .row__col_with-offset_24
430
+ margin-left: 100%
431
+
432
+ @media (min-margin-left: 480px)
433
+ .row__col_with-offset_0_s
434
+ margin-left: 0
435
+
436
+ .row__col_with-offset_1_s
437
+ margin-left: calc(100% / 24)
438
+
439
+ .row__col_with-offset_2_s
440
+ margin-left: calc(100% / 12)
441
+
442
+ .row__col_with-offset_3_s
443
+ margin-left: 12.5%
444
+
445
+ .row__col_with-offset_4_s
446
+ margin-left: calc(100% / 6)
447
+
448
+ .row__col_with-offset_5_s
449
+ margin-left: calc(500% / 24)
450
+
451
+ .row__col_with-offset_6_s
452
+ margin-left: 25%
453
+
454
+ .row__col_with-offset_7_s
455
+ margin-left: calc(700% / 24)
456
+
457
+ .row__col_with-offset_8_s
458
+ margin-left: calc(100% / 3)
459
+
460
+ .row__col_with-offset_9_s
461
+ margin-left: 37.5%
462
+
463
+ .row__col_with-offset_10_s
464
+ margin-left: calc(500% / 12)
465
+
466
+ .row__col_with-offset_11_s
467
+ margin-left: calc(1100% / 24)
468
+
469
+ .row__col_with-offset_12_s
470
+ margin-left: 50%
471
+
472
+ .row__col_with-offset_13_s
473
+ margin-left: calc(1300% / 24)
474
+
475
+ .row__col_with-offset_14_s
476
+ margin-left: calc(700% / 12)
477
+
478
+ .row__col_with-offset_15_s
479
+ margin-left: 62.5%
480
+
481
+ .row__col_with-offset_16_s
482
+ margin-left: calc(200% / 3)
483
+
484
+ .row__col_with-offset_17_s
485
+ margin-left: calc(1700% / 24)
486
+
487
+ .row__col_with-offset_18_s
488
+ margin-left: 75%
489
+
490
+ .row__col_with-offset_19_s
491
+ margin-left: calc(1900% / 24)
492
+
493
+ .row__col_with-offset_20_s
494
+ margin-left: calc(500% / 6)
495
+
496
+ .row__col_with-offset_21_s
497
+ margin-left: 85%
498
+
499
+ .row__col_with-offset_22_s
500
+ margin-left: calc(1100% / 12)
501
+
502
+ .row__col_with-offset_23_s
503
+ margin-left: calc(2300% / 24)
504
+
505
+ .row__col_with-offset_24_s
506
+ margin-left: 100%
507
+
508
+ @media (min-margin-left: 768px) and (max-margin-left: 1024px)
509
+ .row__col_with-offset_0_m
510
+ margin-left: 0
511
+
512
+ .row__col_with-offset_1_m
513
+ margin-left: calc(100% / 24)
514
+
515
+ .row__col_with-offset_2_m
516
+ margin-left: calc(100% / 12)
517
+
518
+ .row__col_with-offset_3_m
519
+ margin-left: 12.5%
520
+
521
+ .row__col_with-offset_4_m
522
+ margin-left: calc(100% / 6)
523
+
524
+ .row__col_with-offset_5_m
525
+ margin-left: calc(500% / 24)
526
+
527
+ .row__col_with-offset_6_m
528
+ margin-left: 25%
529
+
530
+ .row__col_with-offset_7_m
531
+ margin-left: calc(700% / 24)
532
+
533
+ .row__col_with-offset_8_m
534
+ margin-left: calc(100% / 3)
535
+
536
+ .row__col_with-offset_9_m
537
+ margin-left: 37.5%
538
+
539
+ .row__col_with-offset_10_m
540
+ margin-left: calc(500% / 12)
541
+
542
+ .row__col_with-offset_11_m
543
+ margin-left: calc(1100% / 24)
544
+
545
+ .row__col_with-offset_12_m
546
+ margin-left: 50%
547
+
548
+ .row__col_with-offset_13_m
549
+ margin-left: calc(1300% / 24)
550
+
551
+ .row__col_with-offset_14_m
552
+ margin-left: calc(700% / 12)
553
+
554
+ .row__col_with-offset_15_m
555
+ margin-left: 62.5%
556
+
557
+ .row__col_with-offset_16_m
558
+ margin-left: calc(200% / 3)
559
+
560
+ .row__col_with-offset_17_m
561
+ margin-left: calc(1700% / 24)
562
+
563
+ .row__col_with-offset_18_m
564
+ margin-left: 75%
565
+
566
+ .row__col_with-offset_19_m
567
+ margin-left: calc(1900% / 24)
568
+
569
+ .row__col_with-offset_20_m
570
+ margin-left: calc(500% / 6)
571
+
572
+ .row__col_with-offset_21_m
573
+ margin-left: 85%
574
+
575
+ .row__col_with-offset_22_m
576
+ margin-left: calc(1100% / 12)
577
+
578
+ .row__col_with-offset_23_m
579
+ margin-left: calc(2300% / 24)
580
+
581
+ .row__col_with-offset_24_m
582
+ margin-left: 100%
583
+
584
+ @media (min-margin-left: 1024px)
585
+ .row__col_with-offset_0_l
586
+ margin-left: 0
587
+
588
+ .row__col_with-offset_1_l
589
+ margin-left: calc(100% / 24)
590
+
591
+ .row__col_with-offset_2_l
592
+ margin-left: calc(100% / 12)
593
+
594
+ .row__col_with-offset_3_l
595
+ margin-left: 12.5%
596
+
597
+ .row__col_with-offset_4_l
598
+ margin-left: calc(100% / 6)
599
+
600
+ .row__col_with-offset_5_l
601
+ margin-left: calc(500% / 24)
602
+
603
+ .row__col_with-offset_6_l
604
+ margin-left: 25%
605
+
606
+ .row__col_with-offset_7_l
607
+ margin-left: calc(700% / 24)
608
+
609
+ .row__col_with-offset_8_l
610
+ margin-left: calc(100% / 3)
611
+
612
+ .row__col_with-offset_9_l
613
+ margin-left: 37.5%
614
+
615
+ .row__col_with-offset_10_l
616
+ margin-left: calc(500% / 12)
617
+
618
+ .row__col_with-offset_11_l
619
+ margin-left: calc(1100% / 24)
620
+
621
+ .row__col_with-offset_12_l
622
+ margin-left: 50%
623
+
624
+ .row__col_with-offset_13_l
625
+ margin-left: calc(1300% / 24)
626
+
627
+ .row__col_with-offset_14_l
628
+ margin-left: calc(700% / 12)
629
+
630
+ .row__col_with-offset_15_l
631
+ margin-left: 62.5%
632
+
633
+ .row__col_with-offset_16_l
634
+ margin-left: calc(200% / 3)
635
+
636
+ .row__col_with-offset_17_l
637
+ margin-left: calc(1700% / 24)
638
+
639
+ .row__col_with-offset_18_l
640
+ margin-left: 75%
641
+
642
+ .row__col_with-offset_19_l
643
+ margin-left: calc(1900% / 24)
644
+
645
+ .row__col_with-offset_20_l
646
+ margin-left: calc(500% / 6)
647
+
648
+ .row__col_with-offset_21_l
649
+ margin-left: 85%
650
+
651
+ .row__col_with-offset_22_l
652
+ margin-left: calc(1100% / 12)
653
+
654
+ .row__col_with-offset_23_l
655
+ margin-left: calc(2300% / 24)
656
+
657
+ .row__col_with-offset_24_l
658
+ margin-left: 100%
659
+
660
+ /* ** 切り替え系 ** */
661
+ @media (max-width: 1024px)
662
+ .block_sp
663
+ display: block
664
+
665
+ .block_pc
666
+ display: none
667
+
668
+ .iniline_sp
669
+ display: inline
670
+
671
+ .inline_pc
672
+ display: none
673
+
674
+ .flex_sp
675
+ display: flex
676
+
677
+ .flex_pc
678
+ display: none
679
+
680
+ @media (min-width: 1024px)
681
+ .block_sp
682
+ display: none
683
+
684
+ .block_pc
685
+ display: block
686
+
687
+ .iniline_sp
688
+ display: none
689
+
690
+ .inline_pc
691
+ display: inline
692
+
693
+ .flex_sp
694
+ display: none
695
+
696
+ .flex_pc
697
+ display: flex
File without changes
@@ -1,5 +1,11 @@
1
1
  module NippoCore
2
2
  class ApplicationController < ActionController::Base
3
3
  protect_from_forgery with: :exception
4
+ before_action :authenticate_user!
5
+
6
+ private
7
+ def find_group
8
+ @group = NippoCore::Group.find(params[:group_id])
9
+ end
4
10
  end
5
11
  end
@@ -0,0 +1,18 @@
1
+ module NippoCore
2
+ class GroupMemberRelationsController < ApplicationController
3
+ before_action :find_group
4
+
5
+ def new
6
+ @group_member_relations = @group.group_member_relations.new
7
+ end
8
+
9
+ # TODO: Implement test
10
+ def create
11
+ redirect_to home_path and return unless @group.member?(current_user)
12
+ user = NippoCore::User.find(params[:group_member_relation][:user_id])
13
+ @group.add_member(user)
14
+
15
+ redirect_to group_path(@group)
16
+ end
17
+ end
18
+ end
@@ -1,13 +1,22 @@
1
1
  module NippoCore
2
2
  class GroupsController < ApplicationController
3
- before_action :authenticate_user!
4
3
  before_action :initialize_group, only: [:new, :create]
5
4
 
5
+ def index
6
+ @groups = NippoCore::Group.order(created_at: :desc).page(params[:page]).per(10)
7
+ end
8
+
6
9
  def new
7
10
  end
8
11
 
12
+ def show
13
+ @group = NippoCore::Group.find(params[:id])
14
+ @reports = @group.reports.order(reported_at: :desc).limit(5)
15
+ end
16
+
9
17
  def create
10
18
  if @group.save
19
+ @group.add_member(current_user)
11
20
  redirect_to root_path
12
21
  else
13
22
  render 'new', status: 400
@@ -1,5 +1,7 @@
1
1
  module NippoCore
2
2
  class HomeController < ApplicationController
3
+ skip_before_action :authenticate_user!
4
+
3
5
  def index
4
6
  end
5
7
  end
@@ -1,20 +1,25 @@
1
1
  module NippoCore
2
2
  class ReportsController < ApplicationController
3
- before_action :authenticate_user!
3
+ include Pundit
4
4
  before_action :find_group
5
5
  before_action :initialize_report, except: :index
6
6
 
7
+ # TODO: Implement test
7
8
  def index
8
- @reports = @group.reports
9
+ redirect_to home_path unless @group.member?(current_user)
10
+ @reports = @group.reports.order(reported_at: :desc).page(params[:page]).per(10)
9
11
  end
10
12
 
11
13
  def show
14
+ authorize @report
12
15
  end
13
16
 
14
17
  def new
18
+ authorize @report
15
19
  end
16
20
 
17
21
  def create
22
+ authorize @report
18
23
  if @report.save
19
24
  redirect_to group_reports_path(group_id: @group.id)
20
25
  else
@@ -23,10 +28,6 @@ module NippoCore
23
28
  end
24
29
 
25
30
  private
26
- def find_group
27
- @group = NippoCore::Group.find(params[:group_id])
28
- end
29
-
30
31
  def initialize_report
31
32
  # TODO: selectable reported_at
32
33
  @report = @group.reports.find_by(id: params[:id]) || @group.reports.new(report_params.merge(reported_at: Date.today, user: current_user))
@@ -0,0 +1,10 @@
1
+ module NippoCore
2
+ class UsersController < ApplicationController
3
+ before_action :authenticate_user!
4
+
5
+ def show
6
+ @created_groups = current_user.created_groups.order(created_at: :desc).limit(5)
7
+ @joined_groups = current_user.groups.order(created_at: :desc).limit(3)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module NippoCore
2
+ module UserDecorator
3
+ def name
4
+ "#{last_name} #{first_name}"
5
+ end
6
+ end
7
+ end
@@ -2,8 +2,20 @@ module NippoCore
2
2
  class Group < ApplicationRecord
3
3
  belongs_to :creator, class_name: 'NippoCore::User'
4
4
  has_many :reports, dependent: :destroy
5
+ has_many :members, through: :group_member_relations, source: :user
6
+ has_many :group_member_relations, dependent: :destroy
5
7
 
6
8
  validates :creator, presence: true
7
9
  validates :name, presence: true
10
+
11
+ def add_member(user)
12
+ relation = group_member_relations.find_or_initialize_by(user: user, status: false)
13
+ relation.status = true
14
+ relation.save
15
+ end
16
+
17
+ def member?(user)
18
+ group_member_relations.exists?(user_id: user.id, status: true)
19
+ end
8
20
  end
9
21
  end
@@ -0,0 +1,10 @@
1
+ module NippoCore
2
+ class GroupMemberRelation < ApplicationRecord
3
+ belongs_to :user
4
+ belongs_to :group
5
+
6
+ validates :user, presence: true
7
+ validates :group, presence: true
8
+ validates :authentication, presence: true
9
+ end
10
+ end
@@ -7,6 +7,8 @@ module NippoCore
7
7
 
8
8
  has_many :created_groups, class_name: 'NippoCore::Group', foreign_key: 'creator_id', dependent: :destroy
9
9
  has_many :reports, dependent: :destroy
10
+ has_many :groups, through: :group_member_relations
11
+ has_many :group_member_relations, dependent: :destroy
10
12
 
11
13
  validates :last_name, presence: true
12
14
  validates :first_name, presence: true
@@ -0,0 +1,53 @@
1
+ class ApplicationPolicy
2
+ attr_reader :user, :record
3
+
4
+ def initialize(user, record)
5
+ @user = user
6
+ @record = record
7
+ end
8
+
9
+ def index?
10
+ false
11
+ end
12
+
13
+ def show?
14
+ scope.where(:id => record.id).exists?
15
+ end
16
+
17
+ def create?
18
+ false
19
+ end
20
+
21
+ def new?
22
+ create?
23
+ end
24
+
25
+ def update?
26
+ false
27
+ end
28
+
29
+ def edit?
30
+ update?
31
+ end
32
+
33
+ def destroy?
34
+ false
35
+ end
36
+
37
+ def scope
38
+ Pundit.policy_scope!(user, record.class)
39
+ end
40
+
41
+ class Scope
42
+ attr_reader :user, :scope
43
+
44
+ def initialize(user, scope)
45
+ @user = user
46
+ @scope = scope
47
+ end
48
+
49
+ def resolve
50
+ scope
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,27 @@
1
+ module NippoCore
2
+ class ReportPolicy < ApplicationPolicy
3
+ attr_reader :user, :group
4
+
5
+ def initialize(user, report)
6
+ @user = user
7
+ @group = report.group
8
+ end
9
+
10
+ # TODO: remove
11
+ def index?
12
+ @group.member?(user)
13
+ end
14
+
15
+ def show?
16
+ @group.member?(user)
17
+ end
18
+
19
+ def new?
20
+ @group.member?(user)
21
+ end
22
+
23
+ def create?
24
+ @group.member?(user)
25
+ end
26
+ end
27
+ end
@@ -2,9 +2,25 @@ doctype html
2
2
  html
3
3
  head
4
4
  title
5
- | Nippo core
5
+ | 日報
6
6
  = stylesheet_link_tag "nippo_core/application", media: "all"
7
7
  = javascript_include_tag "nippo_core/application"
8
8
  = csrf_meta_tags
9
9
  body
10
+ header.header
11
+ div
12
+ = t('daily report')
13
+ nav
14
+ - if user_signed_in?
15
+ div
16
+ = current_user.nickname
17
+ ul
18
+ - if user_signed_in?
19
+ li
20
+ = link_to t('sign out'), destroy_user_session_path, method: :delete
21
+ - else
22
+ li
23
+ = link_to t('sign in'), new_user_session_path
24
+ li
25
+ = link_to t('sign up'), new_user_registration_path
10
26
  = yield
@@ -0,0 +1,4 @@
1
+ = form_for [@group, @group_member_relations] do |f|
2
+ .field
3
+ = f.collection_select :user_id, NippoCore::User.all, :id, :nickname
4
+ = f.submit
@@ -0,0 +1,12 @@
1
+ h1
2
+ | Group index
3
+ ul
4
+ - @groups.each do |group|
5
+ li
6
+ = link_to group.name, group
7
+ p
8
+ - if group.member?(current_user)
9
+ | Member
10
+ - else
11
+ = link_to 'Join us!', '#'
12
+ = paginate @groups
@@ -0,0 +1,20 @@
1
+ h1
2
+ = @group.name
3
+ section
4
+ h2
5
+ | something
6
+ = simple_format @group.description
7
+ section
8
+ - if @group.member?(current_user)
9
+ h2
10
+ | recently activity
11
+ ul
12
+ - @reports.each do |report|
13
+ li
14
+ = link_to report.title, [@group, report]
15
+ = link_to 'more', group_reports_path(group_id: @group.id)
16
+ = link_to 'new report', new_group_report_path(group_id: @group.id)
17
+ - else
18
+ h2
19
+ | Join us?
20
+ | please click here!
@@ -1,2 +1,13 @@
1
- h1
2
- | Hello World
1
+ - if user_signed_in?
2
+ h1
3
+ | Welcome to Nippo!
4
+ p
5
+ | What do you want to do?
6
+ ul
7
+ li
8
+ = link_to 'Create new group.', new_group_path
9
+ li
10
+ = link_to 'Show your profile.', users_path
11
+ - else
12
+ | If you want to write and share report, please
13
+ = link_to ' sign in!', new_user_session_path
@@ -2,3 +2,4 @@ ul
2
2
  - @reports.each do |report|
3
3
  li
4
4
  = link_to report.title, group_report_path(report, group_id: @group.id)
5
+ = paginate @reports
@@ -0,0 +1,32 @@
1
+ h1
2
+ | Your Profile
3
+ section
4
+ h2
5
+ | Names
6
+ dl
7
+ dt
8
+ | Name
9
+ dd
10
+ = ActiveDecorator::Decorator.instance.decorate(current_user).name
11
+ dt
12
+ | Nickame
13
+ dd
14
+ = current_user.nickname
15
+ section
16
+ h2
17
+ | Groups you created
18
+ ul
19
+ - @created_groups.each do |group|
20
+ li
21
+ = link_to group.name, group
22
+ = link_to 'more', '#'
23
+ = link_to 'create more', new_group_path
24
+ section
25
+ h2
26
+ | Groups you join
27
+ ul
28
+ - @joined_groups.each do |group|
29
+ li
30
+ = link_to group.name, group
31
+ = link_to 'more', '#'
32
+ = link_to 'join more', '#'
@@ -0,0 +1,4 @@
1
+ ja:
2
+ errors:
3
+ messages:
4
+ not_saved: 保存に失敗しました
@@ -0,0 +1,17 @@
1
+ ja:
2
+ daily report: 日報
3
+ sign up: サインアップ
4
+ sign in: サインイン
5
+ sign out: サインアウト
6
+ activerecord:
7
+ attributes:
8
+ nippo_core/user:
9
+ email: メールアドレス
10
+ password: パスワード
11
+ password_confirmation: パスワードの再確認
12
+ last_name: 苗字
13
+ first_name: 名前
14
+ nickname: ニックネーム
15
+ nippo_core/group:
16
+ name: グループ名
17
+ description: 説明
data/config/routes.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  NippoCore::Engine.routes.draw do
2
2
  devise_for :users, class_name: "NippoCore::User", module: :'nippo_core/users'
3
- resources :groups, except: [:index, :edit, :update] do
3
+ resource :users, path: :user, only: :show
4
+ resources :groups, except: [:edit, :update] do
5
+ resources :group_member_relations, path: :group_members, only: [:new, :create]
4
6
  resources :reports, except: [:edit, :update]
5
7
  end
8
+
6
9
  root 'home#index'
7
10
  end
@@ -0,0 +1,14 @@
1
+ class CreateNippoCoreGroupMemberRelations < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :nippo_core_group_member_relations do |t|
4
+ t.integer :user_id, null: false, index: true
5
+ t.foreign_key :nippo_core_users, column: :user_id
6
+ t.integer :group_id, null: false, index: true
7
+ t.foreign_key :nippo_core_groups, column: :group_id
8
+ t.integer :authentication, null: false, default: 0
9
+ t.boolean :status, null: false, default: false
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -2,6 +2,8 @@ require 'slim-rails'
2
2
  require 'devise'
3
3
  require 'active_decorator'
4
4
  require 'redcarpet'
5
+ require 'pundit'
6
+ require 'kaminari'
5
7
 
6
8
  module NippoCore
7
9
  class Engine < ::Rails::Engine
@@ -1,3 +1,3 @@
1
1
  module NippoCore
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nippo_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takumu Uyama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-20 00:00:00.000000000 Z
11
+ date: 2017-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 5.0.2
27
27
  - !ruby/object:Gem::Dependency
28
- name: mysql2
28
+ name: slim-rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: slim-rails
42
+ name: devise
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: devise
56
+ name: active_decorator
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: active_decorator
70
+ name: redcarpet
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,21 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: redcarpet
84
+ name: pundit
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: kaminari
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: mysql2
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: rspec-rails
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +164,8 @@ dependencies:
136
164
  - - ">="
137
165
  - !ruby/object:Gem::Version
138
166
  version: '0'
139
- description: daily report!
167
+ description: When you install this gem, you can report and share a daily report among
168
+ your company group, club, teammate etc.
140
169
  email:
141
170
  - sasurai.usagi3@gmail.com
142
171
  executables: []
@@ -149,7 +178,10 @@ files:
149
178
  - app/assets/config/nippo_core_manifest.js
150
179
  - app/assets/javascripts/nippo_core/application.js
151
180
  - app/assets/stylesheets/nippo_core/application.css
181
+ - app/assets/stylesheets/nippo_core/config.sass
182
+ - app/assets/stylesheets/nippo_core/style.sass
152
183
  - app/controllers/nippo_core/application_controller.rb
184
+ - app/controllers/nippo_core/group_member_relations_controller.rb
153
185
  - app/controllers/nippo_core/groups_controller.rb
154
186
  - app/controllers/nippo_core/home_controller.rb
155
187
  - app/controllers/nippo_core/reports_controller.rb
@@ -159,16 +191,24 @@ files:
159
191
  - app/controllers/nippo_core/users/registrations_controller.rb
160
192
  - app/controllers/nippo_core/users/sessions_controller.rb
161
193
  - app/controllers/nippo_core/users/unlocks_controller.rb
194
+ - app/controllers/nippo_core/users_controller.rb
162
195
  - app/decorators/nippo_core/report_decorator.rb
196
+ - app/decorators/nippo_core/user_decorator.rb
163
197
  - app/helpers/nippo_core/application_helper.rb
164
198
  - app/jobs/nippo_core/application_job.rb
165
199
  - app/mailers/nippo_core/application_mailer.rb
166
200
  - app/models/nippo_core/application_record.rb
167
201
  - app/models/nippo_core/group.rb
202
+ - app/models/nippo_core/group_member_relation.rb
168
203
  - app/models/nippo_core/report.rb
169
204
  - app/models/nippo_core/user.rb
205
+ - app/policies/application_policy.rb
206
+ - app/policies/nippo_core/report_policy.rb
170
207
  - app/views/layouts/nippo_core/application.slim
208
+ - app/views/nippo_core/group_member_relations/new.slim
209
+ - app/views/nippo_core/groups/index.slim
171
210
  - app/views/nippo_core/groups/new.slim
211
+ - app/views/nippo_core/groups/show.slim
172
212
  - app/views/nippo_core/home/index.slim
173
213
  - app/views/nippo_core/reports/index.slim
174
214
  - app/views/nippo_core/reports/new.slim
@@ -185,13 +225,17 @@ files:
185
225
  - app/views/nippo_core/users/registrations/new.slim
186
226
  - app/views/nippo_core/users/sessions/new.slim
187
227
  - app/views/nippo_core/users/shared/_links.slim
228
+ - app/views/nippo_core/users/show.slim
188
229
  - app/views/nippo_core/users/unlocks/new.slim
189
230
  - config/initializers/devise.rb
190
231
  - config/locales/devise.en.yml
232
+ - config/locales/devise.ja.yml
233
+ - config/locales/ja.yml
191
234
  - config/routes.rb
192
235
  - db/migrate/20170420094814_devise_create_nippo_core_users.rb
193
236
  - db/migrate/20170420102455_create_nippo_core_groups.rb
194
237
  - db/migrate/20170420110055_create_nippo_core_reports.rb
238
+ - db/migrate/20170420155712_create_nippo_core_group_member_relations.rb
195
239
  - lib/nippo_core.rb
196
240
  - lib/nippo_core/engine.rb
197
241
  - lib/nippo_core/version.rb
@@ -219,5 +263,5 @@ rubyforge_project:
219
263
  rubygems_version: 2.5.2
220
264
  signing_key:
221
265
  specification_version: 4
222
- summary: This is a daily report system
266
+ summary: This is a daily report system for Rails application.
223
267
  test_files: []