Skip to content

Commit

Permalink
Merge pull request #194 from zediious/0.5.2.4
Browse files Browse the repository at this point in the history
Changes for 0.5.2.4
  • Loading branch information
zediious authored Jul 14, 2024
2 parents 1d0b78d + ac90257 commit 98709de
Show file tree
Hide file tree
Showing 65 changed files with 916 additions and 2,611 deletions.
17 changes: 17 additions & 0 deletions raptorWeb/authprofiles/migrations/0018_alter_raptoruser_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.7 on 2024-07-14 15:52

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("authprofiles", "0017_raptoruser_mfa_enabled"),
]

operations = [
migrations.AlterModelOptions(
name="raptoruser",
options={"verbose_name": "User", "verbose_name_plural": "Users"},
),
]
4 changes: 4 additions & 0 deletions raptorWeb/authprofiles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ def delete(self, *args, **kwargs):

return super(self.__class__, self).delete(*args, **kwargs)

class Meta:
verbose_name = "User"
verbose_name_plural = "Users"


class RaptorUserGroup(Group):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.7 on 2024-07-13 22:57

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("donations", "0022_alter_completeddonation_options"),
]

operations = [
migrations.AlterModelOptions(
name="completeddonation",
options={
"verbose_name": "Completed Donation",
"verbose_name_plural": "Completion Donations",
},
),
]
6 changes: 5 additions & 1 deletion raptorWeb/donations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DonationServerCommand(models.Model):
"""
A command to be sent to a server. Use {{minecraft_username}}
and {{package_name}} as placeholders for the package that the
player bought when creation commands.
player bought when creating commands.
"""
command = models.CharField(
default="",
Expand Down Expand Up @@ -277,5 +277,9 @@ class Meta:
permissions = [
("resendbenefits_completeddonation", "Can re-send benefits for Completed Donations"),
]

class Meta:
verbose_name = "Completed Donation"
verbose_name_plural = "Completion Donations"


2 changes: 1 addition & 1 deletion raptorWeb/gameservers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def post(self, request: HttpRequest, *args: tuple, **kwargs: dict) -> HttpRespon

changing_server.save()
messages.success(request, f'Maintenance status set to {changing_server.in_maintenance} for {changing_server}.')
return render(request, template_name=join(PANEL_TEMPLATE_DIR, 'crud/panel_maintenance_button.html'), context={
return render(request, template_name=join(PANEL_TEMPLATE_DIR, 'crud/components/panel_maintenance_button.html'), context={
'maintenance_status': changing_server.in_maintenance,
'server': changing_server
})
Expand Down
8 changes: 6 additions & 2 deletions raptorWeb/panel/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from raptorWeb.raptormc.models import SiteInformation, DefaultPages, InformativeText, Page, NotificationToast, NavWidget
from raptorWeb.donations.models import DonationPackage
from raptorWeb.staffapps.models import CreatedStaffApplication
from raptorWeb.staffapps.models import CreatedStaffApplication, StaffApplicationField
from raptorWeb.authprofiles.models import RaptorUser, UserProfileInfo, DiscordUserInfo, RaptorUserGroup
from raptorWeb.gameservers.models import Server

Expand Down Expand Up @@ -267,7 +267,11 @@ class Meta:
}


class PanelCreatedStaffApplicationForm(forms.ModelForm):
class PanelCreatedStaffApplicationForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['form_fields'].queryset = StaffApplicationField.objects.all().order_by('priority')

class Meta:
model = CreatedStaffApplication
fields: str = "__all__"
Expand Down
17 changes: 17 additions & 0 deletions raptorWeb/panel/migrations/0005_alter_panellogentry_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.7 on 2024-07-14 15:02

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("panel", "0004_alter_panellogentry_changed_model"),
]

operations = [
migrations.AlterModelOptions(
name="panellogentry",
options={"verbose_name": "Change List", "verbose_name_plural": "Changes"},
),
]
4 changes: 4 additions & 0 deletions raptorWeb/panel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ class PanelLogEntry(models.Model):
date = models.DateTimeField(
auto_now_add=True
)

class Meta:
verbose_name = 'Change List'
verbose_name_plural = 'Changes'

4 changes: 2 additions & 2 deletions raptorWeb/panel/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
path('api/html/panel/server/list/', views.PanelServerList.as_view(), name="server/list"),
path('api/html/panel/server/archivedlist', views.PanelServerList.as_view(template_name='panel/crud/server_list_archived.html'), name="server/archivedlist"),
path('api/html/panel/server/update/<int:pk>', views.PanelServerUpdate.as_view(), name="server/update_IR"),
path('api/html/panel/server/create/', views.PanelServerCreate.as_view(), name="server/create"),
path('api/html/panel/server/create', views.PanelServerCreate.as_view(), name="server/create"),
path('api/html/panel/server/delete', views.PanelServerDelete.as_view(), name="server/delete"),
# Player
path('api/html/panel/player/list/', views.PanelPlayerList.as_view(), name="player/list"),
path('api/html/panel/player/list', views.PanelPlayerList.as_view(), name="player/list"),
# Informative Text
path('api/html/panel/content/informativetext/list', views.PanelInformativeTextList.as_view(), name="content/informativetext/list"),
path('api/html/panel/content/informativetext/update/<int:pk>', views.PanelInformativeTextUpdate.as_view(), name="content/informativetext/update_IR"),
Expand Down
65 changes: 41 additions & 24 deletions raptorWeb/panel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ class PanelCreateView(CreateView):
"""
Abstract CreateView used in Panel CRUD views
"""
template_name_suffix = "_create_form"
template_name: str = join(TEMPLATE_DIR_PANEL_CRUD, 'generic_create.html')
permission: str = ''
redirect_url: str = ''

Expand Down Expand Up @@ -622,6 +622,14 @@ def post(self, request: HttpRequest, *args: str, **kwargs: Any) -> HttpResponse:
)
return HttpResponse(status=400)

def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
context = super().get_context_data(**kwargs)
context.update({
'crud_url': self.crud_url,
'model': self.model
})
return context


class PanelDeleteView(View):
"""
Expand All @@ -646,8 +654,13 @@ def post(self, request: HttpRequest, *args: tuple, **kwargs: dict) -> HttpRespon
deleting_objects = self.model.objects.filter(pk__in=form_data.keys())

changed_string: str = ''
for model in deleting_objects:
changed_string += f'{model}, '
deleting_objects_count = deleting_objects.count()
if deleting_objects_count > 1:
for model in deleting_objects:
changed_string += f'{model}, '

else:
changed_string += f'{deleting_objects[0]}'

if changed_string == '':
messages.error(request, 'There were no objects to delete!')
Expand All @@ -660,7 +673,11 @@ def post(self, request: HttpRequest, *args: tuple, **kwargs: dict) -> HttpRespon
action='Deleted'
)

messages.success(request, f'{model_string}s: {changed_string[:-2]} have been permanently deleted!')
if deleting_objects_count > 1:
messages.success(request, f'{model_string}s: {changed_string[:-2]} have been permanently deleted!')
else:
messages.success(request, f'{model_string}: {changed_string[:-2]} has been permanently deleted!')

return HttpResponseRedirect(self.redirect_url)


Expand Down Expand Up @@ -695,7 +712,7 @@ class PanelLogEntryList(PanelListViewSearchable):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
'total_panellogentry_count': PanelLogEntry.objects.count()
'total_model_count': PanelLogEntry.objects.count()
})

return context
Expand Down Expand Up @@ -725,8 +742,8 @@ class PanelServerCreate(PanelCreateView):
"""
model: Server = Server
form_class = PanelServerCreateForm
template_name: str = join(TEMPLATE_DIR_PANEL_CRUD, 'server_create.html')
redirect_url: str = '/panel/api/html/panel/server/list/'
crud_url: str = 'server'
permission: str = 'gameservers.add_server'


Expand Down Expand Up @@ -783,7 +800,7 @@ def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
'player_filter_form': PanelPlayerFilterForm({'username': self.request.GET.get('username')}),
'total_player_count': Player.objects.count()
'total_model_count': Player.objects.count()
})

if self.request.GET.get('username') != None:
Expand Down Expand Up @@ -862,8 +879,8 @@ class PanelPageCreate(PanelCreateView):
"""
model: Page = Page
form_class = PanelPageForm
template_name: str = join(TEMPLATE_DIR_PANEL_CRUD, 'page_create.html')
redirect_url: str = '/panel/api/html/panel/content/page/list'
crud_url: str = 'content/page'
permission: str = 'raptormc.add_page'


Expand Down Expand Up @@ -912,8 +929,8 @@ class PanelToastCreate(PanelCreateView):
"""
model: NotificationToast = NotificationToast
form_class = PanelToastForm
template_name: str = join(TEMPLATE_DIR_PANEL_CRUD, 'toast_create.html')
redirect_url: str = '/panel/api/html/panel/content/toast/list'
crud_url: str = 'content/toast'
permission: str = 'raptormc.add_notificationtoast'


Expand Down Expand Up @@ -968,8 +985,8 @@ class PanelNarbarLinkCreate(PanelCreateView):
Return a form to create/add a new Navbar Link
"""
model: NavbarLink = NavbarLink
template_name: str = join(TEMPLATE_DIR_PANEL_CRUD, 'navbarlink_create.html')
redirect_url: str = '/panel/api/html/panel/content/navbarlink/list'
crud_url: str = 'content/navbarlink'
permission: str = 'raptormc.add_navbarlink'
fields = [
'name',
Expand Down Expand Up @@ -1029,8 +1046,8 @@ class PanelNavbarDropdownCreate(PanelCreateView):
Return a form to create/add a new Navbar Dropdown
"""
model: NavbarDropdown = NavbarDropdown
template_name: str = join(TEMPLATE_DIR_PANEL_CRUD, 'navbardropdown_create.html')
redirect_url: str = '/panel/api/html/panel/content/navbardropdown/list'
crud_url: str = 'content/navbardropdown'
permission: str = 'raptormc.add_navbardropdown'
fields = [
'name',
Expand Down Expand Up @@ -1086,8 +1103,8 @@ class PanelNavWidgetCreate(PanelCreateView):
"""
model: NavWidget = NavWidget
form_class: PanelNavWidgetCreateForm = PanelNavWidgetCreateForm
template_name: str = join(TEMPLATE_DIR_PANEL_CRUD, 'navwidget_create.html')
redirect_url: str = '/panel/api/html/panel/content/navwidget/list'
crud_url: str = 'content/navwidget'
permission: str = 'raptormc.add_navwidget'


Expand Down Expand Up @@ -1138,8 +1155,8 @@ class PanelNavWidgetBarCreate(PanelCreateView):
Return a form to create/add a new Nav Widget Bar
"""
model: NavWidgetBar = NavWidgetBar
template_name: str = join(TEMPLATE_DIR_PANEL_CRUD, 'navwidgetbar_create.html')
redirect_url: str = '/panel/api/html/panel/content/navwidgetbar/list'
crud_url: str = 'content/navwidgetbar'
permission: str = 'raptormc.add_navwidgetbar'
fields = [
'name',
Expand Down Expand Up @@ -1172,7 +1189,7 @@ class PanelGlobalAnnouncementList(PanelListViewSearchable):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
'total_globalannouncement_count': GlobalAnnouncement.objects.count()
'total_model_count': GlobalAnnouncement.objects.count()
})
return context

Expand Down Expand Up @@ -1210,7 +1227,7 @@ class PanelServerAnnouncementList(PanelListViewSearchable):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
'total_serverannouncement_count': ServerAnnouncement.objects.count()
'total_model_count': ServerAnnouncement.objects.count()
})
return context

Expand Down Expand Up @@ -1295,8 +1312,8 @@ class PanelDonationPackageCreate(PanelCreateView):
"""
model: DonationPackage = DonationPackage
form_class = PanelDonationPackageCreateForm
template_name: str = join(TEMPLATE_DIR_PANEL_CRUD, 'donationpackage_create.html')
redirect_url: str = '/panel/api/html/panel/donations/donationpackage/list'
crud_url: str = 'donations/donationpackage'
permission: str = 'donations.add_donationpackage'


Expand Down Expand Up @@ -1345,8 +1362,8 @@ class PanelDonationServerCommandCreate(PanelCreateView):
Return a form to create/add a new Donation Server Command.
"""
model: DonationServerCommand = DonationServerCommand
template_name: str = join(TEMPLATE_DIR_PANEL_CRUD, 'donationservercommand_create.html')
redirect_url: str = '/panel/api/html/panel/donations/donationservercommand/list'
crud_url: str = 'donations/donationservercommand'
permission: str = 'donations.add_donationservercommand'
fields = [
'command'
Expand Down Expand Up @@ -1399,8 +1416,8 @@ class PanelDonationDiscordRoleCreate(PanelCreateView):
Return a form to create/add a new Donation Discord Role.
"""
model: DonationDiscordRole = DonationDiscordRole
template_name: str = join(TEMPLATE_DIR_PANEL_CRUD, 'donationdiscordrole_create.html')
redirect_url: str = '/panel/api/html/panel/donations/donationdiscordrole/list'
crud_url: str = 'donations/donationdiscordrole'
permission: str = 'donations.add_donationdiscordrole'
fields = [
'name',
Expand Down Expand Up @@ -1432,7 +1449,7 @@ class PanelCompletedDonationList(PanelListViewSearchable):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
'total_completeddonation_count': CompletedDonation.objects.count()
'total_model_count': CompletedDonation.objects.count()
})
return context

Expand Down Expand Up @@ -1461,7 +1478,7 @@ class PanelSubmittedStaffApplicationList(PanelListViewSearchable):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
'total_submittedstaffapplication_count': SubmittedStaffApplication.objects.count()
'total_model_count': SubmittedStaffApplication.objects.count()
})
return context

Expand Down Expand Up @@ -1519,8 +1536,8 @@ class PanelCreatedStaffApplicationCreate(PanelCreateView):
"""
model: CreatedStaffApplication = CreatedStaffApplication
form_class = PanelCreatedStaffApplicationForm
template_name: str = join(TEMPLATE_DIR_PANEL_CRUD, 'createdstaffapplication_create.html')
redirect_url: str = '/panel/api/html/panel/staffapps/createdstaffapplication/list'
crud_url: str = 'staffapps/createdstaffapplication'
permission: str = 'staffapps.add_createdstaffapplication'


Expand Down Expand Up @@ -1572,8 +1589,8 @@ class PanelStaffApplicationFieldCreate(PanelCreateView):
Return a form to create/add a new Staff Application Field
"""
model: StaffApplicationField = StaffApplicationField
template_name: str = join(TEMPLATE_DIR_PANEL_CRUD, 'staffapplicationfield_create.html')
redirect_url: str = '/panel/api/html/panel/staffapps/staffapplicationfield/list'
crud_url: str = 'staffapps/staffapplicationfield'
permission: str = 'staffapps.add_staffapplicationfield'
fields = [
'name',
Expand Down Expand Up @@ -1616,7 +1633,7 @@ def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
'user_filter_form': PanelPlayerFilterForm({'username': self.request.GET.get('username')}),
'total_user_count': RaptorUser.objects.count()
'total_model_count': RaptorUser.objects.count()
})

if self.request.GET.get('username') != None:
Expand Down Expand Up @@ -1734,8 +1751,8 @@ class PanelRaptorUserGroupCreate(PanelCreateView):
"""
model: RaptorUserGroup = RaptorUserGroup
form_class = PanelRaptorUserGroupForm
template_name: str = join(TEMPLATE_DIR_PANEL_CRUD, 'raptorusergroup_create.html')
redirect_url: str = '/panel/api/html/panel/users/raptorusergroup/list'
crud_url: str = 'users/raptorusergroup'
permission: str = 'authprofiles.add_raptorusergroup'


Expand Down
Loading

0 comments on commit 98709de

Please sign in to comment.