diff --git a/whctools/templates/whctools/list_acl_members.html b/whctools/templates/whctools/list_acl_members.html index e91ce29..421abb9 100644 --- a/whctools/templates/whctools/list_acl_members.html +++ b/whctools/templates/whctools/list_acl_members.html @@ -58,9 +58,9 @@ <h3 class="panel-title">Members of the "{{ acl_name }}" ACL</h3> <td>{{character.corp}}</td> <td>{{character.alliance}}</td> {% if character.is_main %} - <td><a href="/whctools/staff/action/{{character.id}}/reject/removed/{{reject_timers.large_reject}}/acl" class="whcbutton btn btn-danger" role="button" id="kick-all">Kick All</a></td> + <td><a href="/whctools/staff/action/{{character.char_id}}/reject/removed/{{reject_timers.large_reject}}/acl" class="whcbutton btn btn-danger" role="button" id="kick-all">Kick All</a></td> {% else %} - <td><a href="/whctools/staff/action/{{character.id}}/reject/other/{{reject_timers.medium_reject}}/acl" class="whcbutton btn btn-warning" role="button" id="remove-alt">Remove Alt</a></td> + <td><a href="/whctools/staff/action/{{character.char_id}}/reject/other/{{reject_timers.medium_reject}}/acl" class="whcbutton btn btn-warning" role="button" id="remove-alt">Remove Alt</a></td> {% endif %} </tr> {% endfor %} diff --git a/whctools/templates/whctools/staff/staff_apps_in_progress.html b/whctools/templates/whctools/staff/staff_apps_in_progress.html index b96c4eb..267f082 100644 --- a/whctools/templates/whctools/staff/staff_apps_in_progress.html +++ b/whctools/templates/whctools/staff/staff_apps_in_progress.html @@ -34,18 +34,18 @@ {% if char.is_main_char and not char.ma_is_valid %} <div class="whctools-error"><i class="fa fas fa-exclamation-triangle"></i> Failed to fetch skills from Member Audit.<br>Refresh page or ask player to re-register if it persists.</div> {% else %} - <button class="whcbutton btn btn-primary openSkillcheckPopup" data-character-id="{{ char.application.eve_character_id }}">Check Skills</button> + <button class="whcbutton btn btn-primary openSkillcheckPopup" data-character-id="{{ char.application.eve_character.character_id }}">Check Skills</button> {% endif %} </td> <td> - <select class="acl-dropdown" data-character-id="{{ char.application.eve_character.id }}"> + <select class="acl-dropdown" data-character-id="{{ char.application.eve_character.character_id }}"> {% for acl in existing_acls %} <option value="{{ acl.name }}">{{ acl.name }}</option> {% endfor %} </select> <button class="whcbutton btn btn-primary accept-button" role="button">Accept</button> - <a href="/whctools/staff/action/{{ char.application.eve_character.id }}/reject/skills/{{ reject_timers.short_reject }}" class="whcbutton btn btn-warning" role="button">Reject: Skills</a> - <a href="/whctools/staff/action/{{ char.application.eve_character.id }}/reject/other/{{ reject_timers.medium_reject }}" class="whcbutton btn btn-danger" role="button">Reject: Other</a> + <a href="/whctools/staff/action/{{ char.application.eve_character.character_id }}/reject/skills/{{ reject_timers.short_reject }}" class="whcbutton btn btn-warning" role="button">Reject: Skills</a> + <a href="/whctools/staff/action/{{ char.application.eve_character.character_id }}/reject/other/{{ reject_timers.medium_reject }}" class="whcbutton btn btn-danger" role="button">Reject: Other</a> </td> </tr> {% endfor %} diff --git a/whctools/templates/whctools/staff/staff_rejected_apps.html b/whctools/templates/whctools/staff/staff_rejected_apps.html index 3980d29..0a278b7 100644 --- a/whctools/templates/whctools/staff/staff_rejected_apps.html +++ b/whctools/templates/whctools/staff/staff_rejected_apps.html @@ -32,7 +32,7 @@ <div>{{char.get_reject_reason_display}}</div> </td> <td> - <a href="/whctools/staff/action/{{char.eve_character.id}}/reset" class="whcbutton btn btn-danger" role="button">Reset</a> + <a href="/whctools/staff/action/{{char.eve_character.character_id}}/reset" class="whcbutton btn btn-danger" role="button">Reset</a> </td> </tr> {% endfor %} diff --git a/whctools/views.py b/whctools/views.py index f5aa8d6..7711d40 100644 --- a/whctools/views.py +++ b/whctools/views.py @@ -214,7 +214,7 @@ def withdraw(request, char_id, acl_name="WHC"): def accept(request, char_id, acl_name="WHC"): whcapplication = Applications.objects.filter( - eve_character_id=char_id + eve_character__character_id=char_id ).select_related("eve_character") if whcapplication: @@ -257,71 +257,72 @@ def reject(request, char_id, reason, days, source="staff", acl_name="WHC"): redirect_target = redirect("/whctools/staff/open") whcapplication = Applications.objects.filter(eve_character__character_id=char_id) - - if whcapplication.exists(): - logger.debug(whcapplication) - else: + if not whcapplication.exists(): logger.error(f"Cannot find character {char_id} to delete.") return redirect_target - if whcapplication: # @@@ move this into template - member_application = whcapplication[0] - old_state = member_application.member_state - notify_subject = "Application Denied" - - # Removed should only be triggered by the removal by staff directly after a membership is allready accepted - if reason == "removed": - # If a WHC character is forcefully removed, remove all alts as well. - logger.debug( - f"Removing {member_application.eve_character.character_name} and all their alts from {acl_name}" - ) - rejection_reason = Applications.RejectionStates.REMOVED - notify_subject = "Membership Revoked" - notification_names = remove_all_alts( - acl_name, - member_application, - Applications.MembershipStates.REJECTED, - rejection_reason, - days, - ) + # @@@ move this into template? + member_application = whcapplication[0] + old_state = member_application.member_state + notify_subject = "Application Denied" - else: - # Other can be used for individual removal of alts that need cleaning up. - # note: currently only used on the reject an open application - additional @@@ TODO to hook up to the remove membership page - logger.debug( - f"Singleton removal of {member_application.eve_character.character_name}" - ) + # Removed should only be triggered by the removal by staff directly after a membership is allready accepted + if reason == "removed": + # If a WHC character is forcefully removed, remove all alts as well. + logger.debug( + f"Removing {member_application.eve_character.character_name} and all their alts from {acl_name}" + ) + rejection_reason = Applications.RejectionStates.REMOVED + notify_subject = "Membership Revoked" + notification_names = remove_all_alts( + acl_name, + member_application, + Applications.MembershipStates.REJECTED, + rejection_reason, + days, + ) - rejection_reason = ( - Applications.RejectionStates.SKILLS - if reason == "skills" - else Applications.RejectionStates.OTHER - ) - notification_names = member_application.eve_character.character_name - remove_character_from_community( - member_application, - Applications.MembershipStates.REJECTED, - rejection_reason, - days, - ) - remove_character_from_acl( - member_application.eve_character.character_id, - acl_name, - old_state, - member_application.member_state, - rejection_reason, - ) + else: + # Other can be used for individual removal of alts that need cleaning up. + # note: currently only used on the reject an open application - additional @@@ TODO to hook up to the remove membership page + logger.debug( + f"Singleton removal of {member_application.eve_character.character_name}" + ) - log_application_change( - application=member_application, old_state=old_state, reason=rejection_reason + rejection_reason = ( + Applications.RejectionStates.SKILLS + if reason == "skills" + else Applications.RejectionStates.OTHER + ) + notification_names = member_application.eve_character.character_name + remove_character_from_community( + member_application, + Applications.MembershipStates.REJECTED, + rejection_reason, + days, ) + remove_character_from_acl( + member_application.eve_character.character_id, + acl_name, + old_state, + member_application.member_state, + rejection_reason, + ) + + log_application_change( + application=member_application, old_state=old_state, reason=rejection_reason + ) + try: + # If this is an orphan, we won't know who to notify since there's no associated user. notify.danger( member_application.eve_character.character_ownership.user, f"{acl_name} Community: {notify_subject}", f"Your application to the {acl_name} Community on {notification_names} has been rejected.\n\n\t* Reason: {member_application.get_reject_reason_display()}" + "\n\nIf you have any questions about this action, please contact WHC Community Coordinators on discord.", - ) + ) + except: + pass return redirect_target @@ -329,7 +330,7 @@ def reject(request, char_id, reason, days, source="staff", acl_name="WHC"): @permission_required("whctools.whc_officer") def reset(request, char_id, acl_name="WHC"): - whcapplication = Applications.objects.filter(eve_character_id=char_id) + whcapplication = Applications.objects.filter(eve_character__character_id=char_id) if whcapplication: member_application = whcapplication[0] @@ -442,7 +443,7 @@ def list_acl_members(request, acl_pk=""): char_list.append({ "name": name, - "id": char_id, + "char_id": char_id, "main": main, "corp": corp, "alliance": alliance, diff --git a/whctools/views_staff/open_applications.py b/whctools/views_staff/open_applications.py index 492c2a3..98b8e44 100644 --- a/whctools/views_staff/open_applications.py +++ b/whctools/views_staff/open_applications.py @@ -78,7 +78,7 @@ def all_characters_currently_with_open_apps(): def getSkills(eve_char_id): application = Applications.objects.filter( - eve_character_id=eve_char_id + eve_character__character_id=eve_char_id ).select_related("eve_character")[0] existing_acls = Acl.objects.all()