Skip to content

Commit ceb1751

Browse files
authored
Merge pull request #199 from zediious/0.5.5
Changes for 0.5.5
2 parents 03d1507 + cc9ead9 commit ceb1751

File tree

6 files changed

+69
-26
lines changed

6 files changed

+69
-26
lines changed

raptorWeb/raptorbot/discordbot/bot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ async def on_ready() -> None:
8282
task_check.check_tasks.start(raptor_bot)
8383
LOGGER.info("Started task check loop")
8484

85+
await presence.update_member_count(raptor_bot)
86+
LOGGER.info('Updated Discord Guild to currently set guild.')
87+
8588
except Exception as e:
8689
LOGGER.error(e)
8790

raptorWeb/raptorbot/discordbot/util/presence.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ async def update_member_count(bot_instance: commands.Bot) -> None:
5858
online_members += 1
5959

6060
try:
61-
await DiscordGuild.objects.aget(guild_id = server.id)
62-
await DiscordGuild.objects.filter(guild_id = server.id).aupdate(
61+
await DiscordGuild.objects.afirst().aupdate(
6362
total_members = member_total,
64-
online_members = online_members
63+
online_members = online_members,
64+
guild_name = server.name,
65+
guild_id = server.id,
6566
)
6667

6768
except DiscordGuild.DoesNotExist:

raptorWeb/raptorbot/views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,6 @@ def post(self, request: HttpRequest, *args: tuple, **kwargs: dict) -> HttpRespon
215215
messages.error(request, "You cannot send commands to the Discord Bot when it is not running.")
216216
return HttpResponse(status=204)
217217

218+
botware.send_command_update_members()
218219
messages.success(request, "Member counts for the Discord Guild have been updated.")
219220
return HttpResponse(status=204)

raptorWeb/raptormc/models.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
from django_resized import ResizedImageField
1212

13+
from raptorWeb.raptorbot.models import DiscordBotTasks
14+
1315
LOGGER: Logger = getLogger('raptormc.models')
1416

1517
class DonationCurrencyChoices(models.TextChoices):
@@ -952,6 +954,11 @@ def post_save_site_info(sender, instance, *args, **kwargs):
952954
instance.avatar_image)
953955
small_site_info.save()
954956
LOGGER.info("New Avatar Image detected, new favicon created from it.")
957+
958+
if instance.discord_global_announcement_channel or instance.discord_staff_role or instance.discord_guild:
959+
tasks: DiscordBotTasks = DiscordBotTasks.objects.get_or_create(pk=1)[0]
960+
tasks.update_members = True
961+
tasks.save()
955962

956963
@receiver(pre_save, sender=NotificationToast)
957964
def strip_script_tags(sender, instance, *args, **kwargs):

raptorWeb/raptormc/routes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def _get_main_routes():
100100
continue
101101

102102
gathered_text = informative_texts.filter(name=f'{str(pattern.name).title()} Information')
103-
if gathered_text is not None:
103+
if gathered_text.exists():
104104
current_routes.append(
105105
Route(
106106
name=pattern.name,
@@ -165,7 +165,7 @@ def _verify_route(current_route):
165165
main_routes = _get_main_routes()
166166
if len(found_route) > 0:
167167

168-
if main_routes.name == 'main_with_text':
168+
if main_routes.route_type == 'main_with_text':
169169
return {
170170
"og_color": site_info.main_color,
171171
"og_url": f"{WEB_PROTO}://{DOMAIN_NAME}/{request_path}",

raptorWeb/templates/panel/crud/completeddonation_view.html

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,51 @@
22
<title>{{ site_info_model.brand_name }} | Completed Donation from {{object.minecraft_username}} on {{object.donation_datetime}}</title>
33
</head>
44

5+
<div class="card bg-dark text-center text-white p-3 mb-2">
6+
<p class='fs-5 text-wrap' data-bs-toggle="tooltip" data-bs-title="{{ object.donation_datetime|date }} at {{ object.donation_datetime|time }}">
7+
<span class="fs-3">{{ object.donation_datetime|timesince }} ago</span>
8+
</p>
9+
</div>
10+
511
<div class='card bg-dark text-white p-3'>
612
<div class='d-flex flex-wrap justify-content-evenly m-3 text-center gap-1'>
7-
{% if completeddonation.donating_user %}
8-
<p class='fs-5 badge bg-secondary'>
9-
<a style="color: #ffffff" target="_blank" href="{{completeddonation.donating_user.get_absolute_url}}">{{completeddonation.donating_user}}</a>
10-
</p>
11-
{% endif %}
12-
<p class='fs-5 badge bg-secondary'>
13-
Minecraft Username: {{ object.minecraft_username }}
14-
</p>
15-
<p class='fs-5 badge bg-secondary'>
16-
Discord Username: {%if object.discord_username%}{{object.discord_username}}{%else%}Discord Username: None{%endif%}
17-
</p>
18-
<p class='fs-5 badge bg-primary'>
19-
Date: {{ object.donation_datetime|date }} | {{ object.donation_datetime|time }}
20-
</p>
13+
<div class="card-header">
14+
{% if completeddonation.donating_user %}
15+
<p class='fs-5 badge bg-secondary text-wrap'>
16+
<a style="color: #ffffff" target="_blank" href="{{completeddonation.donating_user.get_absolute_url}}">Site User: <span class="fs-3">{{completeddonation.donating_user}}</span></a>
17+
</p>
18+
{% endif %}
19+
<p class='fs-5 badge bg-secondary text-wrap'>
20+
Minecraft Username: <span class="fs-3">{{ object.minecraft_username }}</span>
21+
</p>
22+
{% if completeddonation.discord_username %}
23+
<p class='fs-5 badge bg-secondary text-wrap'>
24+
Discord Username: <span class="fs-3">{{object.discord_username}}</span>
25+
</p>
26+
{% endif %}
27+
</div>
28+
</div>
29+
<div class='d-flex flex-wrap justify-content-evenly m-3 text-center gap-1'>
2130
{% if completeddonation.completed %}
2231
<p class='fs-5 badge bg-success'>
2332
{% else %}
2433
<p class='fs-5 badge bg-warning'>
2534
{% endif %}
26-
<a style="color: #ffffff" target="_blank" href="{{completeddonation.bought_package.get_absolute_url}}">Package: {{completeddonation.bought_package}}</a>
35+
<a style="color: #ffffff" target="_blank" href="{{completeddonation.bought_package.get_absolute_url}}">Package: <span class="fs-3">{{completeddonation.bought_package}}</span></a>
2736
</p>
2837
{% if completeddonation.completed %}
2938
<p class='fs-5 badge bg-success'>
30-
Spent: {{completeddonation.spent}}
39+
Spent: <span class="fs-3 text-wrap">{{completeddonation.spent}}</span>
3140
</p>
3241
{% endif %}
3342
{% if completeddonation.completed %}
3443
<p class='fs-5 badge bg-success'>
35-
Status: Complete
44+
Status: <span class="fs-3 text-wrap">Complete</span>
3645
</p>
3746
{% else %}
3847
<p class='fs-5 badge bg-danger'>
39-
Status: Incomplete
48+
Status: <span class="fs-3 text-wrap">Incomplete</span>
49+
4050
</p>
4151
{% endif %}
4252
</div>
@@ -45,22 +55,43 @@
4555
{% if perms.donations.resendbenefits_completeddonation %}
4656
<form>
4757
{% csrf_token %}
48-
<a role='button' class='btn btn-warning'
58+
<a role='button' class='btn btn-warning' data-bs-toggle="tooltip" data-bs-title="Re-send the commands given for this donation to the assigned gameservers.&#013;WARNING: This can potentially be destructive!"
4959
hx-post="{% url 'donations:resend' %}?pk={{object.pk}}&do_commands=true&do_roles=false"
60+
hx-confirm="Are you sure you want to re-send gameserver commands for this donation?"
61+
hx-disabled-elt="this"
5062
hx-swap='none'
5163
>
5264
Re-send Commands
5365
</a>
5466
</form>
5567
<form>
5668
{% csrf_token %}
57-
<a role='button' class='btn btn-warning'
69+
<a role='button' class='btn btn-warning' data-bs-toggle="tooltip" data-bs-title="Re-give the Discord roles given for this donation to the assigned Discord users.&#013;WARNING: This can potentially be destructive!"
5870
hx-post="{% url 'donations:resend' %}?pk={{object.pk}}&do_commands=false&do_roles=true"
71+
hx-confirm="Are you sure you want to re-give Discord roles for this donation?"
72+
hx-disabled-elt="this"
5973
hx-swap='none'
6074
>
6175
Re-give Roles
6276
</a>
6377
</form>
6478
{% endif %}
6579
</div>
66-
</div>
80+
<div class='d-flex flex-wrap justify-content-evenly m-3 text-center gap-1'>
81+
<p class='fs-5 badge bg-success text-wrap'>
82+
Times commands sent: <span class="fs-3 text-wrap">{{completeddonation.sent_commands_count}}</span>
83+
</p>
84+
<p class='fs-5 badge bg-success text-wrap'>
85+
Times roles given: <span class="fs-3 text-wrap">{{completeddonation.gave_roles_count}}</span>
86+
</p>
87+
</div>
88+
</div>
89+
90+
<script>
91+
try {
92+
tooltipTriggerList
93+
} catch (error) {
94+
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
95+
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
96+
}
97+
</script>

0 commit comments

Comments
 (0)