mirror of https://github.com/Ombi-app/Ombi
pull/733/head
parent
29ae064c7a
commit
f7bf2a2fe7
@ -0,0 +1,62 @@
|
||||
using PlexRequests.Core.SettingModels;
|
||||
using PlexRequests.Helpers.Permissions;
|
||||
|
||||
namespace PlexRequests.Core.Users
|
||||
{
|
||||
public static class UserManagementHelper
|
||||
{
|
||||
|
||||
public static int GetPermissions(UserManagementSettings settings)
|
||||
{
|
||||
var permission = 0;
|
||||
|
||||
if (settings.AutoApproveMovies)
|
||||
{
|
||||
permission += (int)Permissions.AutoApproveMovie;
|
||||
}
|
||||
if (settings.AutoApproveMusic)
|
||||
{
|
||||
permission += (int)Permissions.AutoApproveAlbum;
|
||||
}
|
||||
if (settings.AutoApproveTvShows)
|
||||
{
|
||||
permission += (int)Permissions.AutoApproveTv;
|
||||
}
|
||||
if (settings.RequestMovies)
|
||||
{
|
||||
permission += (int)Permissions.RequestMovie;
|
||||
}
|
||||
if (settings.RequestMusic)
|
||||
{
|
||||
permission += (int)Permissions.RequestMusic;
|
||||
}
|
||||
if (settings.RequestTvShows)
|
||||
{
|
||||
permission += (int)Permissions.RequestTvShow;
|
||||
}
|
||||
if (settings.ReportIssues)
|
||||
{
|
||||
permission += (int)Permissions.ReportIssue;
|
||||
}
|
||||
|
||||
|
||||
return permission;
|
||||
}
|
||||
|
||||
public static int GetFeatures(UserManagementSettings settings)
|
||||
{
|
||||
var features = 0;
|
||||
|
||||
if (settings.RecentlyAddedNewsletter)
|
||||
{
|
||||
features += (int)Features.Newsletter;
|
||||
}
|
||||
if (settings.RecentlyAddedNotification)
|
||||
{
|
||||
features += (int)Features.Newsletter;
|
||||
}
|
||||
|
||||
return features;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
@using PlexRequests.UI.Helpers
|
||||
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<PlexRequests.Core.SettingModels.UserManagementSettings>
|
||||
@Html.Partial("_Sidebar")
|
||||
|
||||
<div class="col-sm-8 col-sm-push-1">
|
||||
<form class="form-horizontal" method="POST" id="mainForm">
|
||||
<fieldset>
|
||||
<legend>User Management Settings</legend>
|
||||
|
||||
<span>Here you can manage the default permissions and features that your users get</span>
|
||||
|
||||
|
||||
<h3>Permissions</h3>
|
||||
@Html.Checkbox(Model.RequestMovies, "RequestMovies", "Request Movies");
|
||||
@Html.Checkbox(Model.RequestTvShows, "RequestTvShows", "Request TV Shows");
|
||||
@Html.Checkbox(Model.RequestMusic, "RequestMusic", "Request Music");
|
||||
@Html.Checkbox(Model.AutoApproveMovies, "AutoApproveMovies", "Auto Approve Movie Requests");
|
||||
@Html.Checkbox(Model.AutoApproveTvShows, "AutoApproveTvShows", "Auto Approve TV Show Requests");
|
||||
@Html.Checkbox(Model.AutoApproveMusic, "AutoApproveMusic", "Auto Approve Music Requests");
|
||||
@Html.Checkbox(Model.ReportIssues, "ReportIssues", "Report Issues");
|
||||
|
||||
|
||||
|
||||
<h3>Features</h3>
|
||||
@Html.Checkbox(Model.RecentlyAddedNewsletter, "RecentlyAddedNewsletter", "Recently Added Newsletter");
|
||||
@Html.Checkbox(Model.RecentlyAddedNotification, "RecentlyAddedNotification", "Recently Added Notifications");
|
||||
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<button type="submit" id="save" class="btn btn-primary-outline">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
$('#save').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var $form = $("#mainForm");
|
||||
|
||||
var data = $form.serialize();
|
||||
|
||||
$.ajax({
|
||||
type: $form.prop("method"),
|
||||
data: data,
|
||||
url: $form.prop("action"),
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
if (response.result === true) {
|
||||
generateNotify("Success!", "success");
|
||||
} else {
|
||||
generateNotify(response.message, "warning");
|
||||
}
|
||||
},
|
||||
error: function (e) {
|
||||
console.log(e);
|
||||
generateNotify("Something went wrong!", "danger");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
Loading…
Reference in new issue