mirror of
https://github.com/placeAtlas/atlas.git
synced 2024-12-26 07:54:01 +01:00
Use different flair for edit
This commit is contained in:
parent
d9107ac6df
commit
41ab1f0d20
1 changed files with 32 additions and 16 deletions
|
@ -88,8 +88,8 @@ def set_flair(submission, flair):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (submission.link_flair_text == "New Entry"):
|
if submission.link_flair_text == "New Entry" or submission.link_flair_text == "Edit Entry":
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
@ -106,24 +106,40 @@ def set_flair(submission, flair):
|
||||||
|
|
||||||
if submission_json:
|
if submission_json:
|
||||||
|
|
||||||
submission_json_dummy = {"id": submission.id, "edit": True, "contributors": []}
|
if submission.link_flair_text == "Edit Entry":
|
||||||
|
|
||||||
|
assert submission_json["id"] != 0, "ID is tampered, it must not be 0!"
|
||||||
|
submission_json_dummy = {"id": submission_json["id"], "edit": True, "contributors": []}
|
||||||
|
|
||||||
|
if "submitted_by" in submission_json:
|
||||||
|
submission_json_dummy["contributors"].append(submission_json['submitted_by'])
|
||||||
|
del submission_json['submitted_by']
|
||||||
|
elif "contributors" in submission_json:
|
||||||
|
submission_json_dummy["contributors"] = submission_json["contributors"]
|
||||||
|
|
||||||
|
try:
|
||||||
|
if not submission.author.name in submission_json_dummy:
|
||||||
|
submission_json_dummy["contributors"].append(submission.author.name)
|
||||||
|
except AttributeError:
|
||||||
|
submission_json_dummy["contributors"].append("unknown")
|
||||||
|
|
||||||
if (submission_json.id != 0):
|
|
||||||
submission_json_dummy["id"] = submission_json.id
|
|
||||||
else:
|
else:
|
||||||
del submission_json_dummy["edit"]
|
|
||||||
|
|
||||||
if "submitted_by" in submission_json:
|
assert submission_json["id"] == 0, "ID is tampered, it must be 0!"
|
||||||
submission_json_dummy["contributors"].append(submission_json['submitted_by'])
|
submission_json_dummy = {"id": submission.id, "contributors": []}
|
||||||
del submission_json['submitted_by']
|
|
||||||
elif "contributors" in submission_json:
|
if "submitted_by" in submission_json:
|
||||||
submission_json_dummy["contributors"] = submission_json["contributors"]
|
submission_json_dummy["contributors"].append(submission_json['submitted_by'])
|
||||||
|
del submission_json['submitted_by']
|
||||||
|
elif "contributors" in submission_json:
|
||||||
|
submission_json_dummy["contributors"] = submission_json["contributors"]
|
||||||
|
|
||||||
|
try:
|
||||||
|
if not submission.author.name in submission_json_dummy:
|
||||||
|
submission_json_dummy["contributors"].append(submission.author.name)
|
||||||
|
except AttributeError:
|
||||||
|
submission_json_dummy["contributors"].append("unknown")
|
||||||
|
|
||||||
try:
|
|
||||||
if not submission.author.name in submission_json_dummy:
|
|
||||||
submission_json_dummy["contributors"].append(submission.author.name)
|
|
||||||
except AttributeError:
|
|
||||||
submission_json_dummy["contributors"].append("unknown")
|
|
||||||
|
|
||||||
for key in submission_json:
|
for key in submission_json:
|
||||||
if not key in submission_json_dummy:
|
if not key in submission_json_dummy:
|
||||||
|
|
Loading…
Reference in a new issue