Skip to content
Permalink
Browse files

Merge branch 'development'

  • Loading branch information...
mjy committed May 21, 2019
2 parents 7313336 + ea69824 commit 944436c21e90444987b8fd10d8c2ec40ae470f5c
Showing with 5,553 additions and 3,085 deletions.
  1. +1 −1 .travis.yml
  2. +1 −2 Gemfile
  3. +3 −6 Gemfile.lock
  4. +7 −0 app/controllers/api/v1/base_controller.rb
  5. +1 −1 app/controllers/{ → api/v1}/ping_controller.rb
  6. +0 −7 app/controllers/api/v1/taxon_names_controller.rb
  7. +20 −15 app/controllers/api_controller.rb
  8. +13 −98 app/controllers/application_controller.rb
  9. +8 −0 app/controllers/concerns/RequestType.rb
  10. +17 −0 app/controllers/concerns/api/authenticate_project_token.rb
  11. +16 −0 app/controllers/concerns/api/authenticate_user_token.rb
  12. +36 −0 app/controllers/concerns/api/intercept.rb
  13. +22 −0 app/controllers/concerns/controller_types.rb
  14. +14 −0 app/controllers/concerns/cookies.rb
  15. +0 −3 app/controllers/concerns/data_controller_configuration/project_data_controller_configuration.rb
  16. +11 −0 app/controllers/concerns/forgery_protection.rb
  17. +0 −37 app/controllers/concerns/intercept_api.rb
  18. +11 −0 app/controllers/concerns/log_recent.rb
  19. +30 −0 app/controllers/concerns/page_meta.rb
  20. +36 −0 app/controllers/concerns/pagination_headers.rb
  21. +8 −0 app/controllers/concerns/request_type.rb
  22. +23 −0 app/controllers/concerns/rescue_from.rb
  23. +54 −0 app/controllers/concerns/token_authentication.rb
  24. +0 −1 app/controllers/geographic_areas_controller.rb
  25. +0 −1 app/controllers/georeferences_controller.rb
  26. +4 −3 app/controllers/otus_controller.rb
  27. +1 −0 app/controllers/people_controller.rb
  28. +1 −3 app/controllers/projects_controller.rb
  29. +1 −1 app/controllers/taxon_name_classifications_controller.rb
  30. +12 −0 app/helpers/projects_helper.rb
  31. +1 −0 app/helpers/taxon_names/catalog_helper.rb
  32. +38 −10 app/helpers/workbench/sessions_helper.rb
  33. +2 −2 app/javascript/style/application.scss
  34. +5 −2 app/javascript/vue/browse_annotations/app.vue
  35. +48 −10 app/javascript/vue/browse_annotations/components/view/requestBar.vue
  36. +0 −1 app/javascript/vue/components/annotator/components/asserted_distributions/table.vue
  37. +1 −5 app/javascript/vue/components/annotator/components/biological_relationships/table.vue
  38. +0 −1 app/javascript/vue/components/annotator/components/citations/table.vue
  39. +90 −30 app/javascript/vue/components/annotator/components/common_names/main.vue
  40. +0 −1 app/javascript/vue/components/annotator/components/shared/tableList.vue
  41. +21 −15 app/javascript/vue/components/csvButton.vue
  42. +1 −1 app/javascript/vue/components/radial_object/radialObject.vue
  43. +10 −0 app/javascript/vue/helpers/getPagination.js
  44. +10 −1 app/javascript/vue/nomenclature/new_taxon_name/app.vue
  45. +22 −2 app/javascript/vue/nomenclature/new_taxon_name/components/statusPicker.vue
  46. +11 −0 app/javascript/vue/nomenclature/new_taxon_name/request/resources.js
  47. +5 −2 app/javascript/vue/nomenclature/new_taxon_name/store/actions/actions.js
  48. +20 −0 app/javascript/vue/nomenclature/new_taxon_name/store/actions/updateTaxonStatus.js
  49. +1 −1 app/javascript/vue/nomenclature/new_taxon_name/store/mutations/addTaxonStatus.js
  50. +3 −0 app/javascript/vue/tasks/digitize/app.vue
  51. +93 −0 app/javascript/vue/tasks/digitize/components/biologicalAssociation/biological.vue
  52. +242 −0 app/javascript/vue/tasks/digitize/components/biologicalAssociation/main.vue
  53. +96 −0 app/javascript/vue/tasks/digitize/components/biologicalAssociation/newCitation.vue
  54. +125 −0 app/javascript/vue/tasks/digitize/components/biologicalAssociation/related.vue
  55. +113 −0 app/javascript/vue/tasks/digitize/components/biologicalAssociation/table.vue
  56. +27 −0 app/javascript/vue/tasks/digitize/components/shared/item_tag.vue
  57. +35 −0 app/javascript/vue/tasks/digitize/request/resources.js
  58. +4 −1 app/javascript/vue/tasks/labels/print_labels/app.vue
  59. +5 −1 app/javascript/vue/tasks/labels/print_labels/components/PreviewLabels.vue
  60. +15 −0 app/javascript/vue/tasks/labels/print_labels/components/StyleSelector.vue
  61. +235 −0 app/javascript/vue/tasks/labels/print_labels/components/customStyle.vue
  62. +5 −3 app/javascript/vue/tasks/labels/print_labels/helpers/createLabels.js
  63. +44 −15 app/javascript/vue/tasks/people/author_by_letter/app.vue
  64. +20 −4 app/javascript/vue/tasks/people/author_by_letter/components/author_list.vue
  65. +14 −4 app/javascript/vue/tasks/people/author_by_letter/components/author_row_component.vue
  66. +96 −0 app/javascript/vue/tasks/people/author_by_letter/components/pagination.vue
  67. +4 −1 app/javascript/vue/tasks/people/author_by_letter/components/source_list.vue
  68. +4 −3 app/javascript/vue/tasks/people/author_by_letter/components/source_row_component.vue
  69. +1 −1 app/javascript/vue/tasks/taxon_names/filter/components/filter.vue
  70. +71 −12 app/javascript/vue/tasks/uniquify/people/app.vue
  71. +3 −1 app/javascript/vue/tasks/uniquify/people/components/found_people.vue
  72. +8 −1 app/javascript/vue/tasks/uniquify/people/components/match_people.vue
  73. +0 −1 app/javascript/vue/type_specimens/components/typeBox.vue
  74. +1 −1 app/models/georeference/geo_locate.rb
  75. +1 −1 app/models/georeference/verbatim_data.rb
  76. +4 −5 app/models/otu.rb
  77. +18 −2 app/models/project.rb
  78. +15 −8 app/models/protonym.rb
  79. +1 −1 app/models/protonym/becomes.rb
  80. +620 −129 app/models/protonym/soft_validation_extensions.rb
  81. +5 −1 app/models/source/bibtex.rb
  82. +47 −45 app/models/taxon_name.rb
  83. +27 −17 app/models/taxon_name_classification.rb
  84. +3 −2 app/models/taxon_name_classification/icn/effectively_published.rb
  85. +3 −0 app/models/taxon_name_classification/icn/effectively_published/invalidly_published.rb
  86. +3 −0 app/models/taxon_name_classification/icn/effectively_published/invalidly_published/as_synonym.rb
  87. +3 −0 app/models/taxon_name_classification/icn/effectively_published/invalidly_published/nomen_nudum.rb
  88. +3 −0 app/models/taxon_name_classification/icn/effectively_published/invalidly_published/non_binomial.rb
  89. +3 −0 app/models/taxon_name_classification/icn/effectively_published/invalidly_published/not_latin.rb
  90. +3 −0 app/models/taxon_name_classification/icn/effectively_published/invalidly_published/provisional.rb
  91. +3 −0 ...s/taxon_name_classification/icn/effectively_published/invalidly_published/rejected_publication.rb
  92. +3 −0 app/models/taxon_name_classification/icn/effectively_published/invalidly_published/tautonym.rb
  93. +3 −0 app/models/taxon_name_classification/icn/effectively_published/validly_published.rb
  94. +3 −0 app/models/taxon_name_classification/icn/effectively_published/validly_published/illegitimate.rb
  95. +3 −0 ...els/taxon_name_classification/icn/effectively_published/validly_published/illegitimate/homonym.rb
  96. +3 −0 ...ification/icn/effectively_published/validly_published/illegitimate/incorrect_original_spelling.rb
  97. +3 −0 ...taxon_name_classification/icn/effectively_published/validly_published/illegitimate/superfluous.rb
  98. +3 −0 app/models/taxon_name_classification/icn/effectively_published/validly_published/legitimate.rb
  99. +0 −1 app/models/taxon_name_classification/icn/not_effectively_published.rb
  100. +3 −0 app/models/taxon_name_classification/icnp/effectively_published.rb
  101. +3 −0 app/models/taxon_name_classification/icnp/effectively_published/invalidly_published.rb
  102. +3 −0 app/models/taxon_name_classification/icnp/effectively_published/invalidly_published/nomen_nudum.rb
  103. +3 −0 app/models/taxon_name_classification/icnp/effectively_published/validly_published.rb
  104. +3 −0 app/models/taxon_name_classification/icnp/effectively_published/validly_published/illegitimate.rb
  105. +3 −0 ...ls/taxon_name_classification/icnp/effectively_published/validly_published/illegitimate/homonym.rb
  106. +3 −0 ..._classification/icnp/effectively_published/validly_published/illegitimate/not_in_official_list.rb
  107. +3 −0 ...s/taxon_name_classification/icnp/effectively_published/validly_published/illegitimate/rejected.rb
  108. +3 −0 app/models/taxon_name_classification/icnp/effectively_published/validly_published/legitimate.rb
  109. +3 −0 ...s/taxon_name_classification/icnp/effectively_published/validly_published/legitimate/candidatus.rb
  110. +3 −0 ...dels/taxon_name_classification/icnp/effectively_published/validly_published/legitimate/correct.rb
  111. +3 −0 ...ls/taxon_name_classification/icnp/effectively_published/validly_published/legitimate/incorrect.rb
  112. +3 −0 .../taxon_name_classification/icnp/effectively_published/validly_published/legitimate/nomen_novum.rb
  113. +3 −0 ...axon_name_classification/icnp/effectively_published/validly_published/legitimate/official_list.rb
  114. +0 −3 app/models/taxon_name_classification/icnp/not_effectively_published.rb
  115. +3 −0 app/models/taxon_name_classification/iczn/available.rb
  116. +3 −0 app/models/taxon_name_classification/iczn/available/invalid.rb
  117. +3 −0 app/models/taxon_name_classification/iczn/available/invalid/homonym.rb
  118. +4 −0 ...models/taxon_name_classification/iczn/available/official_list_of_family_group_names_in_zoology.rb
  119. +4 −0 app/models/taxon_name_classification/iczn/available/official_list_of_generic_names_in_zoology.rb
  120. +4 −0 app/models/taxon_name_classification/iczn/available/official_list_of_specific_names_in_zoology.rb
  121. +4 −0 app/models/taxon_name_classification/iczn/available/official_list_of_works_approved_as_available.rb
  122. +5 −0 app/models/taxon_name_classification/iczn/available/valid.rb
  123. +3 −0 app/models/taxon_name_classification/iczn/available/valid/nomen_dubium.rb
  124. +3 −0 app/models/taxon_name_classification/iczn/available/valid/nomen_inquirendum.rb
  125. +3 −0 app/models/taxon_name_classification/iczn/unavailable.rb
  126. +36 −8 app/models/taxon_name_classification/iczn/unavailable/excluded.rb
  127. +89 −3 app/models/taxon_name_classification/iczn/unavailable/nomen_nudum.rb
  128. +20 −0 app/models/taxon_name_classification/iczn/unavailable/non_binomial.rb
  129. +3 −0 app/models/taxon_name_classification/iczn/unavailable/suppressed.rb
  130. +4 −0 ..._classification/iczn/unavailable/suppressed/not_in_official_list_of_available_names_in_zoology.rb
  131. +4 −0 ...sification/iczn/unavailable/suppressed/official_index_of_rejected_and_invalid_works_in_zoology.rb
  132. +4 −0 ...ification/iczn/unavailable/suppressed/official_index_of_rejected_family_group_names_in_zoology.rb
  133. +4 −0 ...classification/iczn/unavailable/suppressed/official_index_of_rejected_generic_names_in_zoology.rb
  134. +4 −0 ...lassification/iczn/unavailable/suppressed/official_index_of_rejected_specific_names_in_zoology.rb
  135. +6 −0 app/models/taxon_name_classification/latinized/gender.rb
  136. +1 −1 app/models/taxon_name_classification/latinized/gender/feminine.rb
  137. +1 −1 app/models/taxon_name_classification/latinized/gender/masculine.rb
  138. +6 −0 app/models/taxon_name_classification/latinized/part_of_speech.rb
  139. +13 −0 app/models/taxon_name_classification/latinized/part_of_speech/adjective.rb
  140. +13 −0 app/models/taxon_name_classification/latinized/part_of_speech/participle.rb
  141. +110 −184 app/models/taxon_name_relationship.rb
  142. +11 −0 app/models/taxon_name_relationship/combination.rb
  143. +7 −0 app/models/taxon_name_relationship/hybrid.rb
  144. +11 −0 app/models/taxon_name_relationship/icn.rb
  145. +7 −0 app/models/taxon_name_relationship/icn/accepting/conserved_name.rb
  146. +7 −0 app/models/taxon_name_relationship/icn/accepting/sanctioned_name.rb
  147. +42 −0 app/models/taxon_name_relationship/icn/unaccepting/synonym.rb
  148. +4 −0 app/models/taxon_name_relationship/icn/unaccepting/synonym/heterotypic.rb
  149. +11 −0 app/models/taxon_name_relationship/icn/unaccepting/synonym/homotypic.rb
  150. +7 −0 app/models/taxon_name_relationship/icnp/accepting/conserved_name.rb
  151. +41 −0 app/models/taxon_name_relationship/icnp/unaccepting/synonym.rb
  152. +3 −0 app/models/taxon_name_relationship/icnp/unaccepting/synonym/heterotypic.rb
  153. +11 −0 app/models/taxon_name_relationship/icnp/unaccepting/synonym/homotypic.rb
  154. +8 −0 app/models/taxon_name_relationship/ictv/unaccepting/supressed.rb
  155. +11 −0 app/models/taxon_name_relationship/iczn.rb
  156. +3 −0 app/models/taxon_name_relationship/iczn/invalidating.rb
  157. +39 −0 app/models/taxon_name_relationship/iczn/invalidating/homonym.rb
  158. +3 −0 app/models/taxon_name_relationship/iczn/invalidating/homonym/primary.rb
  159. +8 −0 app/models/taxon_name_relationship/iczn/invalidating/homonym/primary/forgotten.rb
  160. +8 −0 app/models/taxon_name_relationship/iczn/invalidating/homonym/primary/suppressed.rb
  161. +4 −0 app/models/taxon_name_relationship/iczn/invalidating/homonym/secondary.rb
  162. +3 −0 app/models/taxon_name_relationship/iczn/invalidating/misapplication.rb
  163. +41 −0 app/models/taxon_name_relationship/iczn/invalidating/synonym.rb
  164. +11 −0 app/models/taxon_name_relationship/iczn/invalidating/synonym/forgotten_name.rb
  165. +11 −0 app/models/taxon_name_relationship/iczn/invalidating/synonym/objective.rb
  166. +4 −0 app/models/taxon_name_relationship/iczn/invalidating/synonym/subjective.rb
  167. +11 −0 app/models/taxon_name_relationship/iczn/invalidating/synonym/suppression.rb
  168. +3 −0 app/models/taxon_name_relationship/iczn/invalidating/synonym/suppression/conditional.rb
  169. +3 −0 app/models/taxon_name_relationship/iczn/invalidating/synonym/suppression/partial.rb
  170. +3 −0 app/models/taxon_name_relationship/iczn/invalidating/synonym/suppression/total.rb
  171. +3 −0 app/models/taxon_name_relationship/iczn/invalidating/usage.rb
  172. +7 −0 app/models/taxon_name_relationship/iczn/validating/conserved_name.rb
  173. +7 −0 app/models/taxon_name_relationship/iczn/validating/conserved_work.rb
  174. +11 −0 app/models/taxon_name_relationship/original_combination.rb
  175. +15 −0 app/models/taxon_name_relationship/source_classified_as.rb
  176. +3 −1 app/models/taxon_name_relationship/typification.rb
  177. +7 −0 app/models/taxon_name_relationship/typification/family.rb
  178. +3 −0 app/models/taxon_name_relationship/typification/genus.rb
  179. +3 −0 app/models/taxon_name_relationship/typification/genus/original.rb
  180. +3 −0 app/models/taxon_name_relationship/typification/genus/original/original_designation.rb
  181. +4 −0 app/models/taxon_name_relationship/typification/genus/original/original_monotypy.rb
  182. +27 −0 app/models/taxon_name_relationship/typification/genus/subsequent.rb
  183. +15 −2 app/models/taxon_name_relationship/typification/genus/subsequent/ruling_by_commission.rb
  184. +5 −1 app/models/taxon_name_relationship/typification/genus/subsequent/subsequent_designation.rb
  185. +4 −0 app/models/taxon_name_relationship/typification/genus/subsequent/subsequent_monotypy.rb
  186. +3 −0 app/models/taxon_name_relationship/typification/genus/tautonomy.rb
  187. +3 −0 app/models/taxon_name_relationship/typification/genus/tautonomy/absolute.rb
  188. +3 −0 app/models/taxon_name_relationship/typification/genus/tautonomy/linnaean.rb
  189. +0 −3 app/views/api/index.html.erb
  190. +0 −4 app/views/api/index.json.jbuilder
  191. +7 −0 app/views/api/v1/base/index.json.jbuilder
  192. +0 −2 app/views/api/v1/taxon_names/all.json.rabl
  193. +2 −1 app/views/collection_objects/by_identifier.json.jbuilder
  194. +1 −1 app/views/images/show.html.erb
  195. +1 −1 app/views/otus/batch_load/simple/_batch_load.html.erb
  196. +6 −2 app/views/projects/_attributes.html.erb
  197. +4 −2 app/views/projects/_form.html.erb
  198. +9 −0 config/initializers/routing_draw.rb
  199. +2 −2 config/initializers/vendor/kaminari_config.rb
  200. +0 −26 config/initializers/vendor/rabl_init.rb
  201. +5 −1 config/interface/object_radials.yml
  202. +9 −1,192 config/routes.rb
  203. +22 −0 config/routes/annotations.rb
  204. +0 −44 config/routes/api.rb
  205. +174 −0 config/routes/api_v1.rb
  206. +111 −0 config/routes/base.rb
  207. +598 −0 config/routes/data.rb
  208. +360 −0 config/routes/tasks.rb
  209. +5 −0 db/migrate/20181112174838_add_api_access_token_to_project.rb
  210. +14 −14 db/schema.rb
  211. +2 −2 k8s/app.yml
  212. +2 −2 k8s/sandbox.example.app.yml
  213. +1 −1 lib/dwca/gbif_profile/reference.rb
  214. +2 −1 lib/generators/taxonworks/batch_load/batch_load_generator.rb
  215. +2 −2 lib/generators/taxonworks/task/task_generator.rb
  216. +8 −24 lib/generators/taxonworks/task/templates/app.tt
  217. +12 −19 lib/generators/taxonworks/task/templates/main.tt
  218. +1 −1 lib/soft_validation.rb
  219. +2 −2 lib/tasks/import/3i/3i.rake
  220. +2 −2 lib/tasks/import/odonata/odonata.rake
  221. +1 −1 lib/tasks/import/sf/sf_citations.rake
  222. +1 −1 lib/tasks/import/sf/sf_pre_cites.rake
  223. +11 −7 lib/tasks/import/ucd/ucd.rake
  224. +245 −238 package-lock.json
  225. +9 −9 package.json
  226. +17 −9 spec/README.md
  227. +0 −28 spec/controllers/api/v1/taxon_names_controller_spec.rb
  228. +0 −82 spec/controllers/api_controller_spec.rb
  229. +4 −123 spec/controllers/collection_objects_controller_spec.rb
  230. +5 −0 spec/factories/project_factory.rb
  231. 0 spec/features/{serial_chronologies_spec.rb → _scaffold_spec.rb}
  232. +0 −71 spec/features/api/v1/otus_spec.rb
  233. +35 −8 spec/features/api_spec.rb
  234. +0 −25 spec/features/biocuration_classifications_spec.rb
  235. +0 −30 spec/features/citation_topics_spec.rb
  236. +4 −6 spec/features/collecting_events_spec.rb
  237. +0 −24 spec/features/container_items_spec.rb
  238. +0 −25 spec/features/containers_spec.rb
  239. +0 −19 spec/features/geographic_area_types_spec.rb
  240. +0 −23 spec/features/geographic_areas_geographic_items_spec.rb
  241. +0 −24 spec/features/geographic_items_spec.rb
  242. +0 −32 spec/features/loan_items_spec.rb
  243. +0 −27 spec/features/otu_page_layout_sections_spec.rb
  244. +0 −23 spec/features/public_contents_spec.rb
  245. +1 −1 spec/features/sources_spec.rb
  246. +0 −23 spec/features/tagged_section_keywords_spec.rb
  247. +1 −1 spec/lib/dwca/gbif_profile/core_taxon_spec.rb
  248. +2 −2 spec/models/otu_spec.rb
  249. +22 −15 spec/models/project_spec.rb
  250. +17 −19 spec/models/protonym_specs/soft_validation_spec.rb
  251. +10 −10 spec/models/source/bibtex_spec.rb
  252. +1 −1 spec/models/source/cached_spec.rb
  253. +33 −6 spec/models/taxon_name_classification_spec.rb
  254. +19 −10 spec/models/taxon_name_relationship_spec.rb
  255. +17 −0 spec/requests/api/v1/base_spec.rb
  256. +15 −0 spec/requests/api/v1/ping_spec.rb
  257. +55 −0 spec/requests/api/v1/project_authentication_spec.rb
  258. +36 −0 spec/requests/api/v1/rest/otus_spec.rb
  259. +44 −0 spec/requests/api/v1/user_authentication_spec.rb
  260. +0 −34 spec/routing/routes/api_routing_spec.rb
  261. +22 −0 spec/support/concerns/request/api.rb
  262. +9 −0 spec/support/requests.rb
  263. +7 −10 spec/support/shared_contexts/shared_geo.rb
  264. +1 −2 spec/support/vendor/capybara.rb
  265. +0 −37 spec/views/api/v1/taxon_names/all_rabl_spec.rb
@@ -17,7 +17,7 @@ branches:
only:
- master
- development
- api
- dates
addons:
postgresql: "10"
firefox: "latest"
@@ -36,7 +36,6 @@ gem 'postgresql_cursor', '~> 0.6.1'
gem 'gpx', '~> 1.0.0'

# API/controllers
gem 'rabl', '~> 0.14'
gem 'jbuilder', '~> 2.7'
gem 'responders', '~> 2.4' # Used?!

@@ -144,7 +143,7 @@ end
group :test do
gem 'rspec', '~> 3.6'
gem 'coveralls', '~> 0.8.22', require: false
gem 'capybara', '~> 3.16'
gem 'capybara', '~> 3.18'
gem 'timecop', '~> 0.9.1'
gem 'webmock', '~> 3.5.1'
gem 'vcr', '~> 4.0.0'
@@ -121,11 +121,11 @@ GEM
with_advisory_lock (>= 4.0.0)
coderay (1.1.2)
concurrent-ruby (1.1.5)
coveralls (0.8.22)
coveralls (0.8.23)
json (>= 1.8, < 3)
simplecov (~> 0.16.1)
term-ansicolor (~> 1.3)
thor (~> 0.19.4)
thor (>= 0.19.4, < 2.0)
tins (~> 1.6)
crack (0.4.3)
safe_yaml (~> 1.0.0)
@@ -303,8 +303,6 @@ GEM
method_source (~> 0.9.0)
psych (3.1.0)
public_suffix (3.0.3)
rabl (0.14.1)
activesupport (>= 2.3.14)
rack (2.0.7)
rack-cors (1.0.3)
rack-proxy (0.6.5)
@@ -527,7 +525,7 @@ DEPENDENCIES
bundler (~> 2.0)
byebug (~> 11.0)
capistrano-npm (~> 1.0.2)
capybara (~> 3.16)
capybara (~> 3.18)
chartkick (~> 3.0.2)
chronic (~> 0.10.2)
chunky_png (~> 1.3.11)
@@ -571,7 +569,6 @@ DEPENDENCIES
postgresql_cursor (~> 0.6.1)
prawn (~> 2.2.2)
psych (~> 3.1.0)
rabl (~> 0.14)
rack-cors (~> 1.0.1)
rails (= 5.2.3)
rails-controller-testing (~> 1.0.2)
@@ -0,0 +1,7 @@
class Api::V1::BaseController < ApiController

def index
render status: 200
end

end
@@ -1,4 +1,4 @@
class PingController < ApplicationController
class Api::V1::PingController < ApiController

def ping
render json: '{"pong": true}', status: :ok

This file was deleted.

@@ -1,20 +1,25 @@
# api requests come through here
class ApiController < ApplicationController
attr_accessor :permitted_projects

before_action :set_permitted_projects
# !! No authentication included at this level, maybe
# only logging/throttling etc.
#
# ! Endpoint authentication requrements are set in routes vi defaults: referenced in includes
class ApiController < ActionController::API

def index
respond_to do |format|
format.json {
render(json: {success: true}, status: 200)
}
end
end
include ActionController::HttpAuthentication::Token::ControllerMethods

protected
include Api::AuthenticateUserToken
include Api::AuthenticateProjectToken
include RequestType
include PaginationHeaders


# attr_accessor :permitted_projects
# before_action :set_permitted_projects

protected

#def set_permitted_projects
# @permitted_projects = sessions_current_user.projects
#end

def set_permitted_projects
@permitted_projects = sessions_current_user.projects
end
end
@@ -1,104 +1,19 @@
# TODO: likely required here because of routes, but it shouldn't be!!
# fixing routes to be static via include shoudl solve this
# require_dependency 'lib/application_enumeration.rb'

class ApplicationController < ActionController::Base
include InterceptApi

include Workbench::SessionsHelper
include ProjectsHelper

include Api::Intercept

include ProjectsHelper # /helpers/projects_helper.rb
include SetHousekeeping
include Tracking::UserTime
include Whitelist

# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :reset_session

rescue_from ActiveRecord::RecordNotFound, with: :record_not_found

rescue_from ActionController::ParameterMissing do |exception|
raise unless request.format == :json
render json: { error: exception }, status: 400
end

attr_writer :is_data_controller, :is_task_controller

# Potentially used
attr_writer :meta_title, :meta_data, :site_name
attr_accessor :meta_description, :meta_keywords, :page_title

helper_method :is_data_controller?, :is_task_controller?

# Potentially used.
helper_method :meta_title, :meta_data, :site_name, :page_title

# after_action :log_user_recent_route

# TODO: Make RecenRoutes modules that handles exceptions, only etc.
def log_user_recent_route
# sessions_current_user.add_recently_visited_to_footprint(request.fullpath, @recent_object) if sessions_current_user
end

# Returns true if the controller is that of data class. See controllers/concerns/data_controller_configuration/ concern.
# Data controllers can not be task controllers.
def is_data_controller?
@is_data_controller
end

# Returns true if the controller is a task controller. See controllers/concerns/task_controller_configuration/ concern.
# Task controllers can not be data controllers.
def is_task_controller?
@is_task_controller
end

def meta_title
@meta_title ||= [@meta_title.presence || @page_title.presence, site_name].compact.join(' | ')
end

def meta_data
@meta_data ||= {
description: @meta_description,
keywords: @meta_keywords
}.delete_if { |_k, v| v.nil? }
end

def site_name
@site_name ||= 'TaxonWorks'
end

def digest_cookie(file, key)
sha256 = Digest::SHA256.file(file)
cookies[key] = sha256.hexdigest
end

def digested_cookie_exists?(file, key)
sha256 = Digest::SHA256.file(file)
cookies[key] == sha256.hexdigest
end

private

def record_not_found
respond_to do |format|
format.html { render plain: '404 Not Found', status: 404 }
format.json { render json: {success: false}, status: 404 }
end
end

def disable_turbolinks
@no_turbolinks = true
end

def set_project_from_params
self.sessions_current_project_id = params[:project_id]
end

def invalid_object(object)
!(!object.try(:project_id) || project_matches(object))
end

def project_matches(object)
object.try(:project_id) == sessions_current_project_id
end

include Cookies
include LogRecent # disabled
include PageMeta
include ControllerTypes
include RescueFrom
include ForgeryProtection
include PaginationHeaders
include RequestType
end
@@ -0,0 +1,8 @@
module RequestType
extend ActiveSupport::Concern

def json_request?
request.format.json?
end

end
@@ -0,0 +1,17 @@
module Api

# Authenticates project_token as required by params assigned in routes.
# If authentication fails a JSON response indicating the failure is returned.
module AuthenticateProjectToken

extend ActiveSupport::Concern

include ActionController::HttpAuthentication::Token::ControllerMethods
include TokenAuthentication

included do
before_action :intercept_project, if: -> { params[:authenticate_project] }
end

end
end
@@ -0,0 +1,16 @@
module Api

# See AuthenticateProjectToken for documentation
module AuthenticateUserToken

extend ActiveSupport::Concern

include ActionController::HttpAuthentication::Token::ControllerMethods
include TokenAuthentication

included do
before_action :intercept_user, if: -> { params[:authenticate_user] }
end

end
end
@@ -0,0 +1,36 @@
module Api
module Intercept

extend ActiveSupport::Concern

include ActionController::HttpAuthentication::Token::ControllerMethods
# include ActionController::HttpAuthentication::Token

include TokenAuthentication

# Handle CORS here as well likely

# headers['Access-Control-Allow-Origin'] = '*'
# headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
# headers['Access-Control-Request-Method'] = '*'
# headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'

included do
before_action :intercept_api, if: -> { /^\/api/ =~ request.path }
end

# @return [True, render]
# If authentication is requried, as defined in the routes,
# then it must pass here.
def intercept_api
@api_request = true

res = intercept_user if params[:authenticate_user]
res = intercept_project if res && params[:authenticate_project]
res = set_project_from_params if res && params[:project_id]

res
end

end
end
@@ -0,0 +1,22 @@
module ControllerTypes
extend ActiveSupport::Concern

included do
attr_writer :is_data_controller, :is_task_controller

# Returns true if the controller is that of data class. See controllers/concerns/data_controller_configuration/ concern.
# Data controllers can not be task controllers.
def is_data_controller?
@is_data_controller
end

# Returns true if the controller is a task controller. See controllers/concerns/task_controller_configuration/ concern.
# Task controllers can not be data controllers.
def is_task_controller?
@is_task_controller
end

helper_method :is_data_controller?, :is_task_controller?
end

end
@@ -0,0 +1,14 @@
module Cookies
extend ActiveSupport::Concern

def digest_cookie(file, key)
sha256 = Digest::SHA256.file(file)
cookies[key] = sha256.hexdigest
end

def digested_cookie_exists?(file, key)
sha256 = Digest::SHA256.file(file)
cookies[key] == sha256.hexdigest
end

end
@@ -6,8 +6,6 @@ module DataControllerConfiguration::ProjectDataControllerConfiguration
before_action :require_sign_in_and_project_selection
end

# protected (?)

# @return [ Arel::Nodes, :unprocessable_entity ]
# wrap the the params gathering, if no valid params
# are provided return as unprocessable
@@ -23,5 +21,4 @@ def annotator_params(params, klass)
end
end


end
@@ -0,0 +1,11 @@
module ForgeryProtection
extend ActiveSupport::Concern

included do
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception

end

end

0 comments on commit 944436c

Please sign in to comment.
You can’t perform that action at this time.