Browse Source

wakapost: turn 'image' into a property that aliases to 'filename'

Fixes issues with post editor removing the image
master
dequis 3 years ago
parent
commit
45e8c2672c
2 changed files with 12 additions and 4 deletions
  1. +3
    -3
      board.py
  2. +9
    -1
      wakapost.py

+ 3
- 3
board.py View File

@@ -215,7 +215,7 @@ class Board(object):
else:
parent, replies = postlist[0], []

images = [x for x in replies if x.image]
images = [x for x in replies if x.filename]

if parent.stickied:
max_replies = config.REPLIES_PER_STICKY
@@ -231,7 +231,7 @@ class Board(object):
while len(replies) > max_replies or len(images) > max_images:
post = replies.pop(0)
thread['omit'] += 1
if post.image:
if post.filename:
thread['omitimages'] += 1

thread['posts'] = [parent] + replies
@@ -723,7 +723,7 @@ class Board(object):
subject=row.subject,
password=row.password,
comment=row.comment,
image=row.image,
image=row.filename,
size=row.size,
md5=row.md5,
width=row.width,


+ 9
- 1
wakapost.py View File

@@ -13,7 +13,7 @@ class WakaPost(object):
__slots__ = [
# columns copied directly from model.board
'num', 'parent', 'timestamp', 'lasthit', 'ip', 'date', 'name', 'trip',
'email', 'subject', 'password', 'comment', 'image', 'size', 'md5',
'email', 'subject', 'password', 'comment', 'size', 'md5',
'width', 'height', 'thumbnail', 'tn_width', 'tn_height', 'lastedit',
'lastedit_ip', '_admin_post', 'stickied', 'locked',
# extensions
@@ -171,6 +171,14 @@ class WakaPost(object):
# TODO: database migration / unfucking
self._admin_post = (value in (True, 1, 'yes', 'True', '1'))

@property
def image(self):
return self.filename

@image.setter
def image(self, value):
self.filename = value

def set_ip(self, numip, editing=None):
'''Sets the ip or the lastedit ip'''
if editing:


Loading…
Cancel
Save