Skip to content

Commit d92bce1

Browse files
committed
model, board.post_stuff: Make <board_table>.{locked,admin_post} Boolean.
misc.find_pch() implemented.
1 parent 77c0033 commit d92bce1

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

board.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def post_stuff(self, parent, name, email, subject, comment, file,
251251
timestamp = time.time()
252252

253253
# Initialize admin_post variable--tells whether or not this post has fallen under the hand of a mod/admin
254-
admin_post = ''
254+
admin_post = False
255255

256256
# check that the request came in as a POST, or from the command line
257257
if local.environ.get('REQUEST_METHOD', '') != 'POST':
@@ -268,16 +268,15 @@ def post_stuff(self, parent, name, email, subject, comment, file,
268268
elif not admin_post_mode:
269269
sticky = 0
270270

271-
# TODO use True/False instead of 'yes'?
272-
if sticky_check['locked'] == 'yes' and not admin_post_mode:
271+
if sticky_check['locked'] and not admin_post_mode:
273272
raise WakaError(strings.THREADLOCKEDERROR)
274273

275274
username = accounttype = ''
276275

277276
# check admin password - allow both encrypted and non-encrypted
278277
if admin_post_mode:
279278
username, accounttype = misc.check_password(admin, 'mpost')
280-
admin_post = 'yes' # TODO use True/False?
279+
admin_post = True
281280
else:
282281
if no_captcha or no_format or (sticky and not parent) or lock:
283282
raise WakaError(strings.WRONGPASS)
@@ -302,8 +301,8 @@ def post_stuff(self, parent, name, email, subject, comment, file,
302301

303302
if lock:
304303
if parent:
305-
threadupdate = threadupdate.values(locked='yes')
306-
lock = 'yes' # TODO use True/False?
304+
threadupdate = threadupdate.values(locked=True)
305+
lock = True
307306

308307
if (sticky or lock) and parent:
309308
session.execute(threadupdate)
@@ -625,10 +624,7 @@ def process_file(self, filestorage, timestamp, parent):
625624
if not width: # unsupported file
626625
if ext in filetypes: # externally defined filetype
627626
# Compensate for absolute paths, if given.
628-
if filetypes[ext].startswith("/"):
629-
icon = filetypes[ext][1:] # FIXME: wtf is wakaba doing here
630-
else:
631-
icon = os.path.join(self.path, filetypes[ext])
627+
icon = os.path.join(self.path, filetypes[ext].lstrip("/"))
632628

633629
tn_ext, tn_width, tn_height = \
634630
analyze_image(open(icon, "rb"), icon)

crypto.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ def rc4(message, key, skip=256):
88
message = [ord(x) for x in message]
99

1010
def swap(x, y):
11-
temp = s[x]
12-
s[x] = s[y]
13-
s[y] = temp
11+
s[x], s[y] = s[y], s[x]
1412

1513
x = y = 0
1614
for x in xrange(256):

misc.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import time
55
import crypt
66
import struct
7+
import strings
78
from subprocess import Popen, PIPE
89

910
import util
@@ -115,7 +116,7 @@ def spam_checker(string):
115116

116117
def spam_engine(trap_fields, spam_files):
117118
def spam_screen():
118-
raise util.WakaError("Anti-spam filters triggered.")
119+
raise util.WakaError(strings.SPAM)
119120

120121
request = local.environ['werkzeug.request']
121122
for field in trap_fields:
@@ -219,8 +220,9 @@ def flood_check(ip, timestamp, comment, file, no_repeat, report_check):
219220
def make_date(timestamp, style, locdays=[]):
220221
return 'today'
221222

222-
def find_pch(filename):
223-
pass
223+
PCH_RE = re.compile('\.[^\.]+$')
224+
def find_pch(image_filename):
225+
return re.sub(PCH_RE, '.pch', image_filename)
224226

225227
def copy_animation_file(pch, image_filename):
226228
pass

model.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import config, config_defaults
22
from sqlalchemy import create_engine
3-
from sqlalchemy import Table, Column, Integer, Text, String, MetaData
3+
from sqlalchemy import Table, Column, Integer, Text, String, MetaData, Boolean
44
from sqlalchemy.orm import sessionmaker, mapper, scoped_session
55
from sqlalchemy.ext.declarative import declarative_base
66

@@ -64,9 +64,10 @@ def board(name):
6464
Column("tn_height", Text), # Thumbnail height in pixels
6565
Column("lastedit", Text), # ADDED - Date of previous edit, as a string
6666
Column("lastedit_ip", Text), # ADDED - Previous editor of the post, if any
67-
Column("admin_post", Text), # ADDED - Admin post?
67+
Column("admin_post", Boolean), # ADDED - Admin post?
68+
# TODO: Probably should make this Boolean. Keeping as int for now to maintain compatibility with sorting functions.
6869
Column("stickied", Integer), # ADDED - Stickied?
69-
Column("locked", Text), # ADDED - Locked?
70+
Column("locked", Boolean), # ADDED - Locked?
7071
)
7172

7273
_boards[name] = table

0 commit comments

Comments
 (0)