-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a verification model, factory, and spec update user, audio event and tag models update gems verification api in progress: - updates abilities - adds permissions, requests specs - adds model schema - adds verification to spec creation_helper add permission spec for verifications update audio_event foreign key constraint on verification model to have cascade delete update expected cascade delete behaviour in models/audio_event_spec.rb to pass test add api spec for verification (shallow + nested) fix cascade deletes model specs fixes users request spec updates spec/README.md add verifications to AudioEventImportFile association scope fix user account spec - users *can* now update their own profile via api due to previous change in #703 adds verification controller helpers extend verification filter slightly + test update verification migration with FK tags cascade delete add required dependants to tags model add cascade delete test on tag spec change permitted params on verification update action adds verification nested filterable removes rails validation on verification; rely on database unique constraint adds request spec for invalid request - duplicate verification updates confirmation enum values: from 'true' to 'correct'; from 'false' to 'incorrect'
- Loading branch information
1 parent
caaffa3
commit 8f61e21
Showing
33 changed files
with
855 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# frozen_string_literal: true | ||
|
||
# VerificationsController | ||
class VerificationsController < ApplicationController | ||
include Api::ControllerHelper | ||
|
||
# GET /verifications | ||
# GET /audio_recordings/:audio_recording_id/audio_events/:audio_event_id/verifications | ||
def index | ||
do_authorize_class | ||
get_audio_event | ||
|
||
@verifications, opts = Settings.api_response.response_advanced( | ||
api_filter_params, | ||
list_permissions, | ||
Verification, | ||
Verification.filter_settings | ||
) | ||
respond_index(opts) | ||
end | ||
|
||
# GET /verifications/:id | ||
# GET /audio_recordings/:audio_recording_id/audio_events/:audio_event_id/verifications/:id | ||
def show | ||
do_load_resource | ||
do_authorize_instance | ||
|
||
respond_show | ||
end | ||
|
||
# GET /verifications/new | ||
def new | ||
do_new_resource | ||
get_resource | ||
do_set_attributes | ||
do_authorize_instance | ||
|
||
respond_new | ||
end | ||
|
||
# POST /verifications | ||
def create | ||
do_new_resource | ||
do_set_attributes(verification_params) | ||
|
||
do_authorize_instance | ||
|
||
if @verification.save | ||
respond_create_success(shallow_verification_url(@verification)) | ||
else | ||
respond_change_fail | ||
end | ||
end | ||
|
||
# PUT/PATCH /verifications/:id | ||
def update | ||
do_load_resource | ||
do_authorize_instance | ||
|
||
if @verification.update(verification_update_params) | ||
respond_show | ||
else | ||
respond_change_fail | ||
end | ||
end | ||
|
||
# Handled in Archivable | ||
# DELETE /verifications/:id | ||
|
||
# GET|POST /verifications/filter | ||
# GET|POST /audio_recordings/:audio_recording_id/audio_events/:audio_event_id/verifications/filter | ||
def filter | ||
do_authorize_class | ||
get_audio_event | ||
|
||
filter_response, opts = Settings.api_response.response_advanced( | ||
api_filter_params, | ||
list_permissions, | ||
Verification, | ||
Verification.filter_settings | ||
) | ||
respond_filter(filter_response, opts) | ||
end | ||
|
||
private | ||
|
||
def verification_params | ||
params.require(:verification).permit( | ||
:confirmed, :audio_event_id, :tag_id | ||
) | ||
end | ||
|
||
def verification_update_params | ||
params.require(:verification).permit( | ||
:confirmed | ||
) | ||
end | ||
|
||
def get_audio_event #rubocop:disable Naming/AccessorMethodName | ||
@audio_event = AudioEvent.find(params[:audio_event_id]) if params&.key?(:audio_event_id) | ||
end | ||
|
||
def list_permissions | ||
Access::ByPermission.audio_event_verifications(current_user, audio_event: @audio_event) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.