mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 16:22:55 -07:00
Added the music request limits
This commit is contained in:
parent
2204559b0a
commit
dbabb43537
4 changed files with 28 additions and 7 deletions
|
@ -16,6 +16,7 @@ namespace Ombi.Core.Models.UI
|
||||||
public UserType UserType { get; set; }
|
public UserType UserType { get; set; }
|
||||||
public int MovieRequestLimit { get; set; }
|
public int MovieRequestLimit { get; set; }
|
||||||
public int EpisodeRequestLimit { get; set; }
|
public int EpisodeRequestLimit { get; set; }
|
||||||
|
public int MusicRequestLimit { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ClaimCheckboxes
|
public class ClaimCheckboxes
|
||||||
|
|
|
@ -12,6 +12,7 @@ export interface IUser {
|
||||||
hasLoggedIn: boolean;
|
hasLoggedIn: boolean;
|
||||||
movieRequestLimit: number;
|
movieRequestLimit: number;
|
||||||
episodeRequestLimit: number;
|
episodeRequestLimit: number;
|
||||||
|
musicRequestLimit: number;
|
||||||
userAccessToken: string;
|
userAccessToken: string;
|
||||||
// FOR UI
|
// FOR UI
|
||||||
checked: boolean;
|
checked: boolean;
|
||||||
|
|
|
@ -102,12 +102,19 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="episodeRequestLimit" class="control-label">Episode Request Limit</label>
|
<label for="episodeRequestLimit" class="control-label">Episode Request Limit</label>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" [(ngModel)]="user.episodeRequestLimit" class="form-control form-small form-control-custom "
|
<input type="text" [(ngModel)]="user.episodeRequestLimit" class="form-control form-small form-control-custom "
|
||||||
id="episodeRequestLimit" name="episodeRequestLimit" value="{{user?.episodeRequestLimit}}">
|
id="episodeRequestLimit" name="episodeRequestLimit" value="{{user?.episodeRequestLimit}}">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="form-group">
|
||||||
|
<label for="musicRequestLimit" class="control-label">Music Request Limit</label>
|
||||||
|
<div>
|
||||||
|
<input type="text" [(ngModel)]="user.musicRequestLimit" class="form-control form-small form-control-custom "
|
||||||
|
id="musicRequestLimit" name="musicRequestLimit" value="{{user?.musicRequestLimit}}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,8 @@ namespace Ombi.Controllers
|
||||||
IRepository<NotificationUserId> notificationRepository,
|
IRepository<NotificationUserId> notificationRepository,
|
||||||
IRepository<RequestSubscription> subscriptionRepository,
|
IRepository<RequestSubscription> subscriptionRepository,
|
||||||
ISettingsService<UserManagementSettings> umSettings,
|
ISettingsService<UserManagementSettings> umSettings,
|
||||||
IRepository<UserNotificationPreferences> notificationPreferences)
|
IRepository<UserNotificationPreferences> notificationPreferences,
|
||||||
|
IMusicRequestRepository musicRepo)
|
||||||
{
|
{
|
||||||
UserManager = user;
|
UserManager = user;
|
||||||
Mapper = mapper;
|
Mapper = mapper;
|
||||||
|
@ -71,6 +72,7 @@ namespace Ombi.Controllers
|
||||||
CustomizationSettings = c;
|
CustomizationSettings = c;
|
||||||
WelcomeEmail = welcome;
|
WelcomeEmail = welcome;
|
||||||
MovieRepo = m;
|
MovieRepo = m;
|
||||||
|
MusicRepo = musicRepo;
|
||||||
TvRepo = t;
|
TvRepo = t;
|
||||||
_log = l;
|
_log = l;
|
||||||
_plexApi = plexApi;
|
_plexApi = plexApi;
|
||||||
|
@ -96,6 +98,7 @@ namespace Ombi.Controllers
|
||||||
private IWelcomeEmail WelcomeEmail { get; }
|
private IWelcomeEmail WelcomeEmail { get; }
|
||||||
private IMovieRequestRepository MovieRepo { get; }
|
private IMovieRequestRepository MovieRepo { get; }
|
||||||
private ITvRequestRepository TvRepo { get; }
|
private ITvRequestRepository TvRepo { get; }
|
||||||
|
private IMusicRequestRepository MusicRepo { get; }
|
||||||
private readonly ILogger<IdentityController> _log;
|
private readonly ILogger<IdentityController> _log;
|
||||||
private readonly IPlexApi _plexApi;
|
private readonly IPlexApi _plexApi;
|
||||||
private readonly ISettingsService<PlexSettings> _plexSettings;
|
private readonly ISettingsService<PlexSettings> _plexSettings;
|
||||||
|
@ -295,7 +298,8 @@ namespace Ombi.Controllers
|
||||||
LastLoggedIn = user.LastLoggedIn,
|
LastLoggedIn = user.LastLoggedIn,
|
||||||
HasLoggedIn = user.LastLoggedIn.HasValue,
|
HasLoggedIn = user.LastLoggedIn.HasValue,
|
||||||
EpisodeRequestLimit = user.EpisodeRequestLimit ?? 0,
|
EpisodeRequestLimit = user.EpisodeRequestLimit ?? 0,
|
||||||
MovieRequestLimit = user.MovieRequestLimit ?? 0
|
MovieRequestLimit = user.MovieRequestLimit ?? 0,
|
||||||
|
MusicRequestLimit = user.MusicRequestLimit ?? 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var role in userRoles)
|
foreach (var role in userRoles)
|
||||||
|
@ -347,6 +351,7 @@ namespace Ombi.Controllers
|
||||||
UserType = UserType.LocalUser,
|
UserType = UserType.LocalUser,
|
||||||
MovieRequestLimit = user.MovieRequestLimit,
|
MovieRequestLimit = user.MovieRequestLimit,
|
||||||
EpisodeRequestLimit = user.EpisodeRequestLimit,
|
EpisodeRequestLimit = user.EpisodeRequestLimit,
|
||||||
|
MusicRequestLimit = user.MusicRequestLimit,
|
||||||
UserAccessToken = Guid.NewGuid().ToString("N"),
|
UserAccessToken = Guid.NewGuid().ToString("N"),
|
||||||
};
|
};
|
||||||
var userResult = await UserManager.CreateAsync(ombiUser, user.Password);
|
var userResult = await UserManager.CreateAsync(ombiUser, user.Password);
|
||||||
|
@ -490,6 +495,7 @@ namespace Ombi.Controllers
|
||||||
user.Email = ui.EmailAddress;
|
user.Email = ui.EmailAddress;
|
||||||
user.MovieRequestLimit = ui.MovieRequestLimit;
|
user.MovieRequestLimit = ui.MovieRequestLimit;
|
||||||
user.EpisodeRequestLimit = ui.EpisodeRequestLimit;
|
user.EpisodeRequestLimit = ui.EpisodeRequestLimit;
|
||||||
|
user.MusicRequestLimit = ui.MusicRequestLimit;
|
||||||
var updateResult = await UserManager.UpdateAsync(user);
|
var updateResult = await UserManager.UpdateAsync(user);
|
||||||
if (!updateResult.Succeeded)
|
if (!updateResult.Succeeded)
|
||||||
{
|
{
|
||||||
|
@ -562,6 +568,7 @@ namespace Ombi.Controllers
|
||||||
// We need to delete all the requests first
|
// We need to delete all the requests first
|
||||||
var moviesUserRequested = MovieRepo.GetAll().Where(x => x.RequestedUserId == userId);
|
var moviesUserRequested = MovieRepo.GetAll().Where(x => x.RequestedUserId == userId);
|
||||||
var tvUserRequested = TvRepo.GetChild().Where(x => x.RequestedUserId == userId);
|
var tvUserRequested = TvRepo.GetChild().Where(x => x.RequestedUserId == userId);
|
||||||
|
var musicRequested = MusicRepo.GetAll().Where(x => x.RequestedUserId == userId);
|
||||||
|
|
||||||
if (moviesUserRequested.Any())
|
if (moviesUserRequested.Any())
|
||||||
{
|
{
|
||||||
|
@ -572,6 +579,11 @@ namespace Ombi.Controllers
|
||||||
await TvRepo.DeleteChildRange(tvUserRequested);
|
await TvRepo.DeleteChildRange(tvUserRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (musicRequested.Any())
|
||||||
|
{
|
||||||
|
await MusicRepo.DeleteRange(musicRequested);
|
||||||
|
}
|
||||||
|
|
||||||
// Delete any issues and request logs
|
// Delete any issues and request logs
|
||||||
var issues = _issuesRepository.GetAll().Where(x => x.UserReportedId == userId);
|
var issues = _issuesRepository.GetAll().Where(x => x.UserReportedId == userId);
|
||||||
var issueComments = _issueCommentsRepository.GetAll().Where(x => x.UserId == userId);
|
var issueComments = _issueCommentsRepository.GetAll().Where(x => x.UserId == userId);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue