Skip to content

Commit

Permalink
Merge pull request #145 from matortheeternal/dev
Browse files Browse the repository at this point in the history
Public Beta Hotfix Release v1.3.1
  • Loading branch information
matortheeternal authored Jan 24, 2017
2 parents 912ddd9 + 0dea2a7 commit 3d0c9bd
Show file tree
Hide file tree
Showing 30 changed files with 213 additions and 84 deletions.
22 changes: 17 additions & 5 deletions mod-picker/app/assets/javascripts/BackendAPI/modListService.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ app.service('modListService', function(backend, $q, userTitleService, contributi
};

this.retrieveModList = function(modListId) {
return backend.retrieve('/mod_lists/' + modListId);
return backend.retrieve('/mod_lists/' + modListId, {
game: window._current_game_id
});
};

this.retrieveActiveModList = function() {
var action = $q.defer();
backend.retrieve('/mod_lists/active').then(function(data) {
backend.retrieve('/mod_lists/active', {
game: window._current_game_id
}).then(function(data) {
if (data.error) {
action.resolve(null);
}
Expand All @@ -31,7 +35,10 @@ app.service('modListService', function(backend, $q, userTitleService, contributi
};

this.setActiveModList = function(modListId) {
return backend.post('/mod_lists/active', {id: modListId});
return backend.post('/mod_lists/active', {
id: modListId,
game: window._current_game_id
});
};

this.starModList = function(modListId, starred) {
Expand Down Expand Up @@ -174,7 +181,10 @@ app.service('modListService', function(backend, $q, userTitleService, contributi
};

this.newModList = function(mod_list, active) {
return backend.post('/mod_lists', {mod_list: mod_list, active: active})
return backend.post('/mod_lists', {
mod_list: mod_list,
active: active
});
};

this.newModListMod = function(mod_list_mod) {
Expand Down Expand Up @@ -287,7 +297,9 @@ app.service('modListService', function(backend, $q, userTitleService, contributi
};

this.addModCollection = function(modListId) {
return backend.post('/mod_lists/' + modListId + '/add', {});
return backend.post('/mod_lists/' + modListId + '/add', {
game: window._current_game_id
});
};

this.hideModList = function(modListId, hidden) {
Expand Down
19 changes: 13 additions & 6 deletions mod-picker/app/assets/javascripts/BackendAPI/modService.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ app.service('modService', function(backend, $q, pageUtils, objectUtils, contribu
return backend.post('/mod_options/search', postData);
};

this.searchModListMods = function(name) {
this.searchModListMods = function(str) {
var postData = {
filters: {
search: name,
search: str,
include_games: true,
utility: false
utility: false,
game: window._current_game_id
}
};
return backend.post('/mods/search', postData);
Expand All @@ -53,19 +54,25 @@ app.service('modService', function(backend, $q, pageUtils, objectUtils, contribu
var postData = {
filters: {
search: str,
utility: true
utility: true,
game: window._current_game_id
}
};
return backend.post('/mods/search', postData);
};

this.searchModsBatch = function(batch) {
return backend.post('/mods/search', { batch: batch });
return backend.post('/mods/search', {
batch: batch,
game: window._current_game_id
});
};

this.retrieveMod = function(modId) {
var action = $q.defer();
backend.retrieve('/mods/' + modId).then(function(data) {
backend.retrieve('/mods/' + modId, {
game: window._current_game_id
}).then(function(data) {
service.associateModImage(data.mod);
action.resolve(data);
}, function(response) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
app.service('moderationService', function(backend) {
this.retrieveStats = function() {
return backend.retrieve("/moderator_cp");
return backend.retrieve("/moderator_cp", {
game: window._current_game_id
});
};
});
8 changes: 6 additions & 2 deletions mod-picker/app/assets/javascripts/BackendAPI/pluginService.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ app.service('pluginService', function(backend, $q, $timeout, recordGroupService,
var plugins = $q.defer();
var postData = {
filters: {
search: filename
search: filename,
game: window._current_game_id
}
};
if (angular.isDefined(modIds)) {
Expand All @@ -57,7 +58,10 @@ app.service('pluginService', function(backend, $q, $timeout, recordGroupService,
};

this.searchPluginsBatch = function(batch) {
return backend.post('/plugins/search', { batch: batch });
return backend.post('/plugins/search', {
batch: batch,
game: window._current_game_id
});
};

//combine dummy_masters array with masters array and sorts the masters array
Expand Down
16 changes: 13 additions & 3 deletions mod-picker/app/assets/javascripts/BackendAPI/userService.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ app.service('userService', function(backend, $q, userSettingsService, userTitleS
if (userData) {
userData.signed_in = true;
userData.permissions = service.getPermissions(userData);
var activeModList = userData.active_mod_lists.find(function(item) {
return item.game_id == window._current_game_id;
});
userData.active_mod_list_id = activeModList && activeModList.mod_list_id;
} else {
userData = { permissions: {} };
}
Expand Down Expand Up @@ -102,14 +106,20 @@ app.service('userService', function(backend, $q, userSettingsService, userTitleS
};

this.changeRole = function(userId, role) {
return backend.post('/users/' + userId + '/change_role', {role: role});
return backend.post('/users/' + userId + '/change_role', {
role: role
});
};

this.retrieveUserModLists = function(userId) {
return backend.retrieve('/users/' + userId + '/mod_lists');
return backend.retrieve('/users/' + userId + '/mod_lists', {
game: window._current_game_id
});
};

this.retrieveUserMods = function(userId) {
return backend.retrieve('/users/' + userId + '/mods');
return backend.retrieve('/users/' + userId + '/mods', {
game: window._current_game_id
});
};
});
2 changes: 1 addition & 1 deletion mod-picker/app/assets/javascripts/Services/listUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ app.service('listUtils', function() {
};

this.getCanInsert = function(key, moveItem) {
return key === "plugin" && moveItem.mod.primary_category.name === "Fixes - Patches";
return key === "plugin" && moveItem.mod.primary_category && moveItem.mod.primary_category.name === "Fixes - Patches";
};

this.moveItem = function(model, key, options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ app.controller('curatorRequestsIndexController', function($scope, $rootScope, $s
// filters for view
$scope.filterPrototypes = filtersFactory.curatorRequestFilters();
$scope.dateFilters = filtersFactory.curatorRequestDateFilters();
$scope.filters = { game: $scope.currentGame.id };

// build generic controller stuff
$scope.route = 'curator_requests';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ app.controller('userSettingsModListsController', function($scope, $rootScope, $t
$scope.retrieveModLists = function() {
var options = {
filters: {
game: window._current_game_id,
submitter: $scope.user.username
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ app.controller('userSettingsModsController', function($scope, columnsFactory, ac
$scope.retrieveMods = function() {
var options = {
filters: {
game: window._current_game_id,
mp_author: $scope.user.username,
sources: {
nexus: true,
Expand Down
2 changes: 1 addition & 1 deletion mod-picker/app/controllers/curator_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def sorting_params

# Params we allow filtering on
def filtering_params
params[:filters].slice(:search, :submitter, :mod_name, :state, :submitted, :updated)
params[:filters].slice(:game, :search, :submitter, :mod_name, :state, :submitted, :updated)
end

end
49 changes: 33 additions & 16 deletions mod-picker/app/controllers/mod_lists_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class ModListsController < ApplicationController
before_action :check_sign_in, only: [:create, :set_active, :update, :import, :update_tags, :create_star, :destroy_star]
before_action :set_mod_list, only: [:show, :hide, :clone, :add, :update, :import, :update_tags, :tools, :mods, :plugins, :export_modlist, :export_plugins, :export_links, :config_files, :analysis, :comments]
before_action :set_mod_list, only: [:hide, :clone, :add, :update, :import, :update_tags, :tools, :mods, :plugins, :export_modlist, :export_plugins, :export_links, :config_files, :analysis, :comments]
before_action :soft_set_mod_list, only: [:set_active]

# GET /mod_lists
def index
Expand All @@ -16,6 +17,7 @@ def index

# GET /mod_lists/1
def show
@mod_list = ModList.game(params[:game]).find(params[:id])
authorize! :read, @mod_list, message: "You are not allowed to view this mod list."
star = current_user.present? && ModListStar.exists?(mod_list_id: @mod_list.id, user_id: current_user.id)
render json: {
Expand All @@ -26,7 +28,7 @@ def show

# GET /mod_lists/active
def active
@mod_list = current_user.present? && current_user.active_mod_list
@mod_list = current_user && current_user.active_mod_list(params[:game])
if @mod_list
respond_with_json(@mod_list, :tracking)
else
Expand Down Expand Up @@ -221,25 +223,24 @@ def clone
# POST /mod_lists/1/add
def add
authorize! :read, @mod_list
@target_mod_list = current_user.active_mod_list
@target_mod_list = current_user.active_mod_list(params[:game])
builder = ModListBuilder.new(@mod_list, @target_mod_list)
builder.copy!
respond_with_json(@target_mod_list, :tracking, :mod_list)
end

# POST /mod_lists/active
def set_active
@mod_list = nil
if params.has_key?(:id) && params[:id]
@mod_list = ModList.find(params[:id])
authorize! :read, @mod_list
end

if current_user.update(active_mod_list_id: params[:id])
render json: { mod_list: nil } unless @mod_list.present?
respond_with_json(@mod_list, :tracking, :mod_list)
ActiveModList.clear(params[:game], current_user)
if @mod_list.present?
@active_mod_list = ActiveModList.new(active_mod_list_params)
if @active_mod_list.save
respond_with_json(@mod_list, :tracking, :mod_list)
else
render json: @active_mod_list.errors, status: :unproccessable_entity
end
else
render json: current_user.errors, status: :unproccessable_entity
render json: { mod_list: nil }
end
end

Expand Down Expand Up @@ -322,6 +323,14 @@ def set_mod_list
@mod_list = ModList.find(params[:id])
end

def soft_set_mod_list
@mod_list = nil
if params.has_key?(:id) && params[:id]
@mod_list = ModList.find(params[:id])
authorize! :read, @mod_list
end
end

def force_download(filename)
response.headers["Content-Disposition"] = "attachment; filename=#{filename}"
end
Expand Down Expand Up @@ -356,7 +365,15 @@ def mod_list_params
)
end

def mod_list_import_params
params.permit(mods: [:id, :name, :nexus_info_id], plugins: [:id, :filename])
end
def mod_list_import_params
params.permit(mods: [:id, :name, :nexus_info_id], plugins: [:id, :filename])
end

def active_mod_list_params
{
game_id: params[:game],
user_id: current_user.id,
mod_list_id: params[:id]
}
end
end
12 changes: 6 additions & 6 deletions mod-picker/app/controllers/moderation_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ def index
raise AccessDenied("You must be a moderator to access this resource.") unless current_user.can_moderate?
render json: {
unapproved: {
curator_requests: CuratorRequest.unapproved_count,
reviews: Review.unapproved_count,
compatibility_notes: CompatibilityNote.unapproved_count,
install_order_notes: InstallOrderNote.unapproved_count,
load_order_notes: LoadOrderNote.unapproved_count,
mods: Mod.unapproved_count,
curator_requests: CuratorRequest.eager_load(:mod).game(params[:game]).unapproved_count,
reviews: Review.game(params[:game]).unapproved_count,
compatibility_notes: CompatibilityNote.game(params[:game]).unapproved_count,
install_order_notes: InstallOrderNote.game(params[:game]).unapproved_count,
load_order_notes: LoadOrderNote.game(params[:game]).unapproved_count,
mods: Mod.game(params[:game]).unapproved_count,
help_pages: HelpPage.unapproved_count
},
unresolved_reports: BaseReport.unresolved_count
Expand Down
8 changes: 4 additions & 4 deletions mod-picker/app/controllers/mods_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def index
# POST /mods/search
def search
if params.has_key?(:batch)
@mods = Mod.find_batch(params[:batch])
@mods = Mod.find_batch(params[:batch], params[:game])
render json: @mods
else
@mods = Mod.visible.filter(search_params).limit(10)
Expand All @@ -26,7 +26,7 @@ def search

# GET /mods/1
def show
@mod = Mod.includes(:custom_sources, :plugins, {mod_authors: :user}, {tags: :submitter}, {required_mods: :required_mod}, {required_by: :mod}).find(params[:id])
@mod = Mod.game(params[:game]).includes(:custom_sources, :plugins, {mod_authors: :user}, {tags: :submitter}, {required_mods: :required_mod}, {required_by: :mod}).find(params[:id])
authorize! :read, @mod, message: "You are not allowed to view this mod."

# set up boolean variables
Expand All @@ -35,8 +35,8 @@ def show
incompatible = false
if current_user.present?
star = ModStar.exists?(mod_id: @mod.id, user_id: current_user.id)
if current_user.active_mod_list_id.present?
mod_list = current_user.active_mod_list
if current_user.active_mod_list(@mod.game_id).present?
mod_list = current_user.active_mod_list(@mod.game_id)
in_mod_list = mod_list.mod_list_mod_ids.include?(@mod.id)
incompatible = mod_list.incompatible_mod_ids.include?(@mod.id)
end
Expand Down
2 changes: 1 addition & 1 deletion mod-picker/app/controllers/plugins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def index
# POST /plugins/search
def search
if params.has_key?(:batch)
@plugins = Plugin.find_batch(params[:batch])
@plugins = Plugin.find_batch(params[:batch], params[:game])
respond_with_json(@plugins, :base)
else
@plugins = Plugin.visible.filter(search_params).limit(10)
Expand Down
9 changes: 4 additions & 5 deletions mod-picker/app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def change_role
def mod_lists
authorize! :read, @user

favorite_mod_lists = @user.starred_mod_lists.accessible_by(current_ability)
authored_mod_lists = @user.mod_lists.accessible_by(current_ability)
favorite_mod_lists = @user.starred_mod_lists.game(params[:game]).accessible_by(current_ability)
authored_mod_lists = @user.mod_lists.game(params[:game]).accessible_by(current_ability)

render json: {
favorites: favorite_mod_lists,
Expand All @@ -134,9 +134,8 @@ def api_tokens
def mods
authorize! :read, @user

favorite_mods = @user.starred_mods.includes(:author_users).accessible_by(current_ability)
authored_mods = @user.mods.includes(:author_users).accessible_by(current_ability)
sources = { nexus: true, lab: true, workshop: true }
favorite_mods = @user.starred_mods.game(params[:game]).includes(:author_users).accessible_by(current_ability)
authored_mods = @user.mods.game(params[:game]).includes(:author_users).accessible_by(current_ability)

render json: {
favorites: json_format(favorite_mods, :index),
Expand Down
Loading

0 comments on commit 3d0c9bd

Please sign in to comment.