Skip to content

Commit

Permalink
Merge pull request #180 from zediious/0.5.1.2
Browse files Browse the repository at this point in the history
Changes for 0.5.2
  • Loading branch information
zediious authored Jun 11, 2024
2 parents da14714 + ca7661b commit 2c2b931
Show file tree
Hide file tree
Showing 56 changed files with 1,832 additions and 1,773 deletions.
7 changes: 1 addition & 6 deletions raptorWeb/donations/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
path('payment/webhook', views.donation_payment_webhook, name="payment_webook"),
path('payment/webhook/', views.donation_payment_webhook, name="payment_webook"),
path('payment/paypal_webhook', include('paypal.standard.ipn.urls')),
# Model Deletion
path('donation/delete/', views.DonationDelete.as_view(), name="donation_delete"),
path('crud/donationpackage/delete/<int:pk>', views.DonationPackageDelete.as_view(), name="donationpackage_delete"),
path('crud/donationservercommand/delete/<int:pk>', views.DonationServerCommandDelete.as_view(), name="donationservercommand_delete"),
path('crud/donationdiscordrole/delete/<int:pk>', views.DonationDiscordRoleDelete.as_view(), name="donationdiscordrole_delete"),
# Admin
# Panel Action
path('donation/resend/', views.DonationBenefitResend.as_view(), name="resend"),
]
117 changes: 1 addition & 116 deletions raptorWeb/donations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
from stripe import Webhook
from stripe.error import SignatureVerificationError

from raptorWeb.panel.models import PanelLogEntry
from raptorWeb.raptormc.models import DefaultPages, SiteInformation
from raptorWeb.donations.models import DonationPackage, CompletedDonation, DonationServerCommand, DonationDiscordRole
from raptorWeb.donations.models import DonationPackage, CompletedDonation
from raptorWeb.donations.forms import SubmittedDonationForm, DonationDiscordUsernameForm, DonationPriceForm, DonationGatewayForm
from raptorWeb.donations.tasks import send_server_commands, add_discord_bot_roles, send_donation_email
from raptorWeb.donations.mojang import verify_minecraft_username
Expand Down Expand Up @@ -245,120 +244,6 @@ def get(self, request: HttpRequest, *args: tuple, **kwargs: dict) -> HttpRespons
return HttpResponseRedirect('/donations/failure')


class DonationDelete(View):
"""
Delete a created donation
"""
def post(self, request: HttpRequest, *args: tuple, **kwargs: dict) -> HttpResponse:
if not DefaultPages.objects.get_or_create(pk=1)[0].donations:
return HttpResponseRedirect('/404')

if not request.user.is_staff:
return HttpResponseRedirect('/404')

if not request.user.has_perm('donations.delete_completeddonation'):
messages.error(request, 'You do not have permission to delete Completed Donations.')
return HttpResponse(status=200)

try:
deleted_donation = CompletedDonation.objects.get(
pk=request.GET.get('pk')
)
deleted_donation.delete()

model_string = str(CompletedDonation).split('.')[3].replace("'", "").replace('>', '')
PanelLogEntry.objects.create(
changing_user=request.user,
changed_model=str(f'{model_string} - {deleted_donation.donation_datetime}'),
action='Deleted'
)

messages.success(request, 'Donation has been permanently deleted!')
return HttpResponseRedirect('/panel/api/html/panel/donations/completeddonation/list')

except CompletedDonation.DoesNotExist:
messages.error(request, 'There was an error processing this package deletion')
return HttpResponse(status=200)


class DonationPackageDelete(View):
"""
Permanently delete a given Donation Package
"""
def get(self, request: HttpRequest, *args: tuple, **kwargs: dict) -> HttpResponse:
if not request.user.is_staff:
return HttpResponseRedirect('/')

if not request.user.has_perm('donations.delete_donationpackage'):
messages.error(request, 'You do not have permission to delete Donation Packages.')
return HttpResponse(status=200)

changing_donationpackage = DonationPackage.objects.get(pk=self.kwargs['pk'])
changing_donationpackage.delete()

model_string = str(DonationPackage).split('.')[3].replace("'", "").replace('>', '')
PanelLogEntry.objects.create(
changing_user=request.user,
changed_model=str(f'{model_string} - {changing_donationpackage}'),
action='Deleted'
)

messages.success(request, f'{changing_donationpackage} has been permanently deleted!')
return HttpResponseRedirect('/panel/api/html/panel/donations/donationpackage/list')


class DonationServerCommandDelete(View):
"""
Permanently delete a given Donation Server Command
"""
def get(self, request: HttpRequest, *args: tuple, **kwargs: dict) -> HttpResponse:
if not request.user.is_staff:
return HttpResponseRedirect('/')

if not request.user.has_perm('donations.delete_donationservercommand'):
messages.error(request, 'You do not have permission to delete Donation Server Commands.')
return HttpResponse(status=200)

changing_donationservercommand = DonationServerCommand.objects.get(pk=self.kwargs['pk'])
changing_donationservercommand.delete()

model_string = str(DonationServerCommand).split('.')[3].replace("'", "").replace('>', '')
PanelLogEntry.objects.create(
changing_user=request.user,
changed_model=str(f'{model_string} - {changing_donationservercommand}'),
action='Deleted'
)

messages.success(request, f'{changing_donationservercommand} has been permanently deleted!')
return HttpResponseRedirect('/panel/api/html/panel/donations/donationservercommand/list')


class DonationDiscordRoleDelete(View):
"""
Permanently delete a given Donation Discord Role
"""
def get(self, request: HttpRequest, *args: tuple, **kwargs: dict) -> HttpResponse:
if not request.user.is_staff:
return HttpResponseRedirect('/')

if not request.user.has_perm('donations.delete_donationdiscordrole'):
messages.error(request, 'You do not have permission to delete Donation Discord Roles.')
return HttpResponse(status=200)

changing_donationdiscordrole = DonationDiscordRole.objects.get(pk=self.kwargs['pk'])
changing_donationdiscordrole.delete()

model_string = str(DonationDiscordRole).split('.')[3].replace("'", "").replace('>', '')
PanelLogEntry.objects.create(
changing_user=request.user,
changed_model=str(f'{model_string} - {changing_donationdiscordrole}'),
action='Deleted'
)

messages.success(request, f'{changing_donationdiscordrole} has been permanently deleted!')
return HttpResponseRedirect('/panel/api/html/panel/donations/donationdiscordrole/list')


class DonationBenefitResend(View):
"""
Re-send benefits for a given completed donation
Expand Down
1 change: 0 additions & 1 deletion raptorWeb/gameservers/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
path('html/server/server_description', views.Server_Description.as_view(), name="server_description"),
path('html/server/maintenance/update/<int:pk>', views.SetMaintenanceMode.as_view(), name="update_maintenance"),
path('html/server/archive/update/<int:pk>', views.SetArchive.as_view(), name="update_archive"),
path('html/server/archive/delete/<int:pk>', views.DeleteServer.as_view(), name="delete"),
# Onboarding
path('html/onboarding/<str:modpack_name>', views.Server_Onboarding.as_view(), name="server_onboarding"),
# Forms
Expand Down
32 changes: 0 additions & 32 deletions raptorWeb/gameservers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from django.contrib import messages
from django.conf import settings

from raptorWeb.panel.models import PanelLogEntry
from raptorWeb.gameservers.models import ServerManager, ServerStatistic, Server, Player, PlayerCountHistoric
from raptorWeb.gameservers.forms import StatisticFilterForm, StatisticFilterFormFireFox
from raptorWeb.raptormc.models import SiteInformation
Expand Down Expand Up @@ -271,37 +270,6 @@ def get(self, request: HttpRequest, *args: tuple, **kwargs: dict) -> HttpRespons
return HttpResponseRedirect('/panel/api/html/panel/server/archivedlist')

return HttpResponseRedirect('/panel/api/html/panel/server/list/')


class DeleteServer(View):
"""
Permanently delete a given server
"""
def get(self, request: HttpRequest, *args: tuple, **kwargs: dict) -> HttpResponse:
if not request.user.is_staff:
return HttpResponseRedirect('/')

if not request.user.has_perm('gameservers.delete_server'):
messages.error(request, 'You do not have permission to delete servers.')
return HttpResponse(status=200)

changing_server = Server.objects.get(pk=self.kwargs['pk'])
if changing_server.archived:
messages.success(request, f'{changing_server} has been permanently deleted!')
changing_server.delete()

model_string = str(Server).split('.')[3].replace("'", "").replace('>', '')
PanelLogEntry.objects.create(
changing_user=request.user,
changed_model=str(f'{model_string} - {changing_server}'),
action='Deleted'
)

return HttpResponseRedirect('/panel/api/html/panel/server/archivedlist')

else:
messages.error(request, f'There was an error attempting to delete {changing_server}!')
return HttpResponse(status=200)


class Import_Servers(TemplateView):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2024-06-10 23:32

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("panel", "0003_panellogentry_action"),
]

operations = [
migrations.AlterField(
model_name="panellogentry",
name="changed_model",
field=models.CharField(max_length=15000),
),
]
2 changes: 1 addition & 1 deletion raptorWeb/panel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PanelLogEntry(models.Model):
)

changed_model = models.CharField(
max_length=500
max_length=15000
)

action = models.CharField(
Expand Down
Loading

0 comments on commit 2c2b931

Please sign in to comment.