-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' for release 5.7.0
- Loading branch information
Showing
685 changed files
with
15,173 additions
and
4,948 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
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
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
50 changes: 50 additions & 0 deletions
50
app/controllers/api/notification_preferences_controller.rb
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,50 @@ | ||
# frozen_string_literal: true | ||
|
||
# API Controller for resources of type Notification Preferences | ||
class API::NotificationPreferencesController < API::ApiController | ||
before_action :authenticate_user! | ||
|
||
def index | ||
@notification_preferences = current_user.notification_preferences | ||
end | ||
|
||
# Currently only available for Admin in NotificationPreferencePolicy | ||
def update | ||
authorize NotificationPreference | ||
notification_type = NotificationType.find_by(name: params[:notification_preference][:notification_type]) | ||
@notification_preference = NotificationPreference.find_or_create_by(notification_type: notification_type, user: current_user) | ||
@notification_preference.update(notification_preference_params) | ||
|
||
if @notification_preference.save | ||
render :show, status: :ok | ||
else | ||
render json: @notification_preference.errors, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
# Currently only available for Admin in NotificationPreferencePolicy | ||
def bulk_update | ||
authorize NotificationPreference | ||
errors = [] | ||
params[:notification_preferences].each do |notification_preference| | ||
notification_type = NotificationType.find_by(name: notification_preference[:notification_type]) | ||
db_notification_preference = NotificationPreference.find_or_create_by(notification_type_id: notification_type.id, user: current_user) | ||
|
||
next if db_notification_preference.update(email: notification_preference[:email], in_system: notification_preference[:in_system]) | ||
|
||
errors.push(db_notification_preference.errors) | ||
end | ||
|
||
if errors.any? | ||
render json: errors, status: :unprocessable_entity | ||
else | ||
head :no_content, status: :ok | ||
end | ||
end | ||
|
||
private | ||
|
||
def notification_preference_params | ||
params.require(:notification_preference).permit(:notification_type_id, :in_system, :email) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
# API Controller for resources of type Notification Types | ||
class API::NotificationTypesController < API::ApiController | ||
before_action :authenticate_user! | ||
|
||
def index | ||
@notification_types = if params[:is_configurable] == 'true' | ||
NotificationType.where(is_configurable: true) | ||
else | ||
NotificationType.all | ||
end | ||
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
Oops, something went wrong.