Skip to content

Commit

Permalink
Resolves #537 add/remove poster headers + linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Decap47662 committed Jan 24, 2023
1 parent d60d54a commit 4f1f84d
Show file tree
Hide file tree
Showing 2 changed files with 344 additions and 173 deletions.
18 changes: 17 additions & 1 deletion faction/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import csv
import datetime
import glob
import html
import json
import math
Expand Down Expand Up @@ -311,14 +312,29 @@ def configurations(request):
context["validMessageSub"] = "Poster header uploaded"
else:
context["errorMessageSub"] = "Error uploading the image (size should be < 500kb)"
if request.POST.get("upload_tail"):
elif request.POST.get("upload_tail"):
form = PosterTailForm(request.POST, request.FILES, instance=faction)
valid_form = form.is_valid()
if valid_form:
form.save()
context["validMessageSub"] = "Poster footer uploaded"
else:
context["errorMessageSub"] = "Error uploading the image (size should be < 500kb)"
elif request.GET.get("delete_header"):
files = glob.glob(os.path.join(settings.MEDIA_ROOT, "posters") + f"/{faction.tId}-head.*")
for file in files:
os.remove(file)
faction.posterHeadImg.delete()
faction.save()
context["validMessageSub"] = "Poster header deleted"

elif request.GET.get("delete_footer"):
files = glob.glob(os.path.join(settings.MEDIA_ROOT, "posters") + f"/{faction.tId}-tail.*")
for file in files:
os.remove(file)
faction.posterTailImg.delete()
faction.save()
context["validMessageSub"] = "Poster footer deleted"

# add poster
if faction.poster:
Expand Down
Loading

0 comments on commit 4f1f84d

Please sign in to comment.