mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 08:16:05 -07:00
Added Paypalme options, no UI yet (#568)
* Added Paypalme options * Added Custom Donation UI * Updated error checking * Review fixes to donation work
This commit is contained in:
parent
6a7ea83f99
commit
41e6d72210
7 changed files with 123 additions and 2 deletions
|
@ -60,6 +60,9 @@ namespace PlexRequests.Core.SettingModels
|
||||||
public bool DisableTvRequestsBySeason { get; set; }
|
public bool DisableTvRequestsBySeason { get; set; }
|
||||||
public bool SendRecentlyAddedEmail { get; set; }
|
public bool SendRecentlyAddedEmail { get; set; }
|
||||||
|
|
||||||
|
public string CustomDonationUrl { get; set; }
|
||||||
|
public bool EnableCustomDonationUrl { get; set; }
|
||||||
|
public string CustomDonationMessage { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The CSS name of the theme we want
|
/// The CSS name of the theme we want
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
52
PlexRequests.UI/Modules/DonationLinkModule.cs
Normal file
52
PlexRequests.UI/Modules/DonationLinkModule.cs
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Nancy;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using NLog;
|
||||||
|
|
||||||
|
using PlexRequests.Core;
|
||||||
|
using PlexRequests.Core.SettingModels;
|
||||||
|
using PlexRequests.Helpers;
|
||||||
|
using PlexRequests.UI.Models;
|
||||||
|
|
||||||
|
namespace PlexRequests.UI.Modules
|
||||||
|
{
|
||||||
|
public class DonationLinkModule : BaseAuthModule
|
||||||
|
{
|
||||||
|
public DonationLinkModule(ICacheProvider provider, ISettingsService<PlexRequestSettings> pr) : base("customDonation", pr)
|
||||||
|
{
|
||||||
|
Cache = provider;
|
||||||
|
|
||||||
|
Get["/", true] = async (x, ct) => await GetCustomDonationUrl(pr);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICacheProvider Cache { get; }
|
||||||
|
|
||||||
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
private async Task<Response> GetCustomDonationUrl(ISettingsService<PlexRequestSettings> pr)
|
||||||
|
{
|
||||||
|
PlexRequestSettings settings = await pr.GetSettingsAsync();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (settings.EnableCustomDonationUrl)
|
||||||
|
{
|
||||||
|
return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Warn("Exception Thrown when attempting to check the custom donation url");
|
||||||
|
Log.Warn(e);
|
||||||
|
return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -248,6 +248,7 @@
|
||||||
<Compile Include="Modules\BaseModule.cs" />
|
<Compile Include="Modules\BaseModule.cs" />
|
||||||
<Compile Include="Modules\BetaModule.cs" />
|
<Compile Include="Modules\BetaModule.cs" />
|
||||||
<Compile Include="Modules\CultureModule.cs" />
|
<Compile Include="Modules\CultureModule.cs" />
|
||||||
|
<Compile Include="Modules\DonationLinkModule.cs" />
|
||||||
<Compile Include="Modules\IssuesModule.cs" />
|
<Compile Include="Modules\IssuesModule.cs" />
|
||||||
<Compile Include="Modules\LandingPageModule.cs" />
|
<Compile Include="Modules\LandingPageModule.cs" />
|
||||||
<Compile Include="Modules\RequestsBetaModule.cs" />
|
<Compile Include="Modules\RequestsBetaModule.cs" />
|
||||||
|
|
|
@ -443,4 +443,7 @@
|
||||||
<data name="Search_ViewInPlex" xml:space="preserve">
|
<data name="Search_ViewInPlex" xml:space="preserve">
|
||||||
<value>View In Plex</value>
|
<value>View In Plex</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Custom_Donation_Default" xml:space="preserve">
|
||||||
|
<value>Donate to Library Maintainer</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
9
PlexRequests.UI/Resources/UI1.Designer.cs
generated
9
PlexRequests.UI/Resources/UI1.Designer.cs
generated
|
@ -114,6 +114,15 @@ namespace PlexRequests.UI.Resources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Donate to Library Maintainer.
|
||||||
|
/// </summary>
|
||||||
|
public static string Custom_Donation_Default {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Custom_Donation_Default", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Issue.
|
/// Looks up a localized string similar to Issue.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -273,10 +273,38 @@
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="checkbox">
|
||||||
|
|
||||||
|
@if (Model.EnableCustomDonationUrl)
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="EnableCustomDonationUrl" name="EnableCustomDonationUrl" checked="checked">
|
||||||
|
<label for="EnableCustomDonationUrl">Enable custom donation link</label>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="EnableCustomDonationUrl" name="EnableCustomDonationUrl"><label for="EnableCustomDonationUrl">Enable custom donation link</label>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="CustomDonationUrl" class="control-label">Custom Donation URL</label>
|
||||||
|
<div>
|
||||||
|
<input type="text" class="form-control-custom form-control " id="CustomDonationUrl" name="CustomDonationUrl" placeholder="http://example.com" value="@Model.CustomDonationUrl">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="CustomDonationMessage" class="control-label">Donation Button Message</label>
|
||||||
|
<div>
|
||||||
|
<input type="text" class="form-control-custom form-control " id="CustomDonationMessage" name="CustomDonationMessage" placeholder="Donation button message" value="@Model.CustomDonationMessage">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<p class="form-group">A comma separated list of users whose requests do not require approval (These users also do not have a request limit).</p>
|
|
||||||
|
<p class="form-group">A comma separated list of users whose requests do not require approval (These users also do not have a request limit).</p>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="NoApprovalUsers" class="control-label">Approval White listed Users</label>
|
<label for="NoApprovalUsers" class="control-label">Approval White listed Users</label>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
@using Nancy.Security
|
@using Nancy.Security
|
||||||
@using Nancy.Session
|
@using Nancy.Session
|
||||||
@using Nancy;
|
@using Nancy;
|
||||||
|
@using PlexRequests.Core.SettingModels
|
||||||
@using PlexRequests.UI.Helpers
|
@using PlexRequests.UI.Helpers
|
||||||
@using PlexRequests.UI.Models
|
@using PlexRequests.UI.Models
|
||||||
@using PlexRequests.UI.Resources
|
@using PlexRequests.UI.Resources
|
||||||
|
@ -38,10 +39,11 @@
|
||||||
{
|
{
|
||||||
<li><a id="donate" href="https://www.paypal.me/PlexRequestsNet" target="_blank"><i class="fa fa-heart" style="color: red"></i> @UI.Layout_Donate</a></li>
|
<li><a id="donate" href="https://www.paypal.me/PlexRequestsNet" target="_blank"><i class="fa fa-heart" style="color: red"></i> @UI.Layout_Donate</a></li>
|
||||||
}
|
}
|
||||||
|
<li id="customDonate" style="display: none"><a id="customDonateHref" href="https://www.paypal.me/PlexRequestsNet" target="_blank"><i class="fa fa-heart" style="color: yellow;"></i> <span id="donationText">@UI.Custom_Donation_Default</span></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
|
|
||||||
|
|
||||||
@if (!Context.CurrentUser.IsAuthenticated() && Context.Request.Session[SessionKeys.UsernameKey] == null) // TODO replace with IsAdmin
|
@if (!Context.CurrentUser.IsAuthenticated() && Context.Request.Session[SessionKeys.UsernameKey] == null) // TODO replace with IsAdmin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -91,5 +93,28 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
var base = '@Html.GetBaseUrl()';
|
||||||
|
var url = createBaseUrl(base, '/customDonation');
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
success: function (result) {
|
||||||
|
console.log("we win + " + result.url);
|
||||||
|
if (result.url && result.url != "donationLinkError") {
|
||||||
|
$("#customDonate").show();
|
||||||
|
var donateLink = $("#customDonateHref");
|
||||||
|
var donationText = $("#donationText");
|
||||||
|
donateLink.attr("href", result.url);
|
||||||
|
if(result.message) {
|
||||||
|
donationText.text(result.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.log("error " + error);
|
||||||
|
$("#customDonate").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<div id="updateAvailable" hidden="hidden"></div>
|
<div id="updateAvailable" hidden="hidden"></div>
|
||||||
</nav>
|
</nav>
|
Loading…
Add table
Add a link
Reference in a new issue