forked from MarseyWorld/MarseyWorld
add the ability to change the author of an asset
parent
9e409beed1
commit
ed29b3b44c
|
@ -1,6 +1,7 @@
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from sqlalchemy import Column, ForeignKey
|
from sqlalchemy import Column, ForeignKey
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
from sqlalchemy.sql.sqltypes import *
|
from sqlalchemy.sql.sqltypes import *
|
||||||
|
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
|
@ -17,6 +18,8 @@ class Emoji(Base):
|
||||||
created_utc = Column(Integer)
|
created_utc = Column(Integer)
|
||||||
nsfw = Column(Boolean, default=False)
|
nsfw = Column(Boolean, default=False)
|
||||||
|
|
||||||
|
author = relationship("User", primaryjoin="User.id==Emoji.author_id")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
|
@ -535,6 +535,7 @@ def update_emoji(v):
|
||||||
file = request.files["image"]
|
file = request.files["image"]
|
||||||
kind = request.values.get('kind', '').strip()
|
kind = request.values.get('kind', '').strip()
|
||||||
new_name = request.values.get('new_name', '').lower().strip()
|
new_name = request.values.get('new_name', '').lower().strip()
|
||||||
|
new_author = request.values.get('new_author', '').lower().strip()
|
||||||
tags = request.values.get('tags', '').lower().strip().replace(' ', ' ')
|
tags = request.values.get('tags', '').lower().strip().replace(' ', ' ')
|
||||||
|
|
||||||
nsfw = request.values.get('nsfw', '').strip()
|
nsfw = request.values.get('nsfw', '').strip()
|
||||||
|
@ -563,6 +564,11 @@ def update_emoji(v):
|
||||||
updated = True
|
updated = True
|
||||||
name = existing.name
|
name = existing.name
|
||||||
|
|
||||||
|
if new_author and existing.author.username.lower() != new_author:
|
||||||
|
author = get_user(new_author)
|
||||||
|
existing.author_id = author.id
|
||||||
|
updated = True
|
||||||
|
|
||||||
if file:
|
if file:
|
||||||
if g.is_tor:
|
if g.is_tor:
|
||||||
stop(400, "File uploads are not allowed through TOR!")
|
stop(400, "File uploads are not allowed through TOR!")
|
||||||
|
@ -653,6 +659,7 @@ def update_hat(v):
|
||||||
|
|
||||||
file = request.files["image"]
|
file = request.files["image"]
|
||||||
new_name = request.values.get('new_name', '').strip()
|
new_name = request.values.get('new_name', '').strip()
|
||||||
|
new_author = request.values.get('new_author', '').lower().strip()
|
||||||
|
|
||||||
existing = g.db.query(HatDef).filter_by(name=name).one_or_none()
|
existing = g.db.query(HatDef).filter_by(name=name).one_or_none()
|
||||||
if not existing:
|
if not existing:
|
||||||
|
@ -677,7 +684,12 @@ def update_hat(v):
|
||||||
existing.name = new_name
|
existing.name = new_name
|
||||||
updated = True
|
updated = True
|
||||||
name = existing.name
|
name = existing.name
|
||||||
|
|
||||||
|
if new_author and existing.author.username.lower() != new_author:
|
||||||
|
author = get_user(new_author)
|
||||||
|
existing.author_id = author.id
|
||||||
|
updated = True
|
||||||
|
|
||||||
if file:
|
if file:
|
||||||
if g.is_tor:
|
if g.is_tor:
|
||||||
stop(400, "File uploads are not allowed through TOR!")
|
stop(400, "File uploads are not allowed through TOR!")
|
||||||
|
|
|
@ -51,6 +51,9 @@
|
||||||
<label class="mt-3" for="new_name">New Name</label>
|
<label class="mt-3" for="new_name">New Name</label>
|
||||||
<input autocomplete="off" type="text" id="new_name" class="form-control" name="new_name" maxlength="30" placeholder="Optional">
|
<input autocomplete="off" type="text" id="new_name" class="form-control" name="new_name" maxlength="30" placeholder="Optional">
|
||||||
|
|
||||||
|
<label class="mt-3" for="new_author">New Author</label>
|
||||||
|
<input autocomplete="off" type="text" id="new_author" class="form-control" name="new_author" maxlength="30" pattern="[a-zA-Z0-9_\- ]{1,30}|\?{3}" placeholder="Optional">
|
||||||
|
|
||||||
{% if type == "Emoji" %}
|
{% if type == "Emoji" %}
|
||||||
<label class="mt-3" for="tags">Additional Tags</label>
|
<label class="mt-3" for="tags">Additional Tags</label>
|
||||||
<input autocomplete="off" type="text" id="name" class="form-control" name="tags" maxlength="200" placeholder="Optional">
|
<input autocomplete="off" type="text" id="name" class="form-control" name="tags" maxlength="200" placeholder="Optional">
|
||||||
|
|
Loading…
Reference in New Issue