Browse Source

model, board.post_stuff: Make <board_table>.{locked,admin_post} Boolean.

misc.find_pch() implemented.
wakabamark
k-anon 10 years ago
parent
commit
d92bce169b
4 changed files with 16 additions and 19 deletions
  1. +6
    -10
      board.py
  2. +1
    -3
      crypto.py
  3. +5
    -3
      misc.py
  4. +4
    -3
      model.py

+ 6
- 10
board.py View File

@@ -251,7 +251,7 @@ class Board(object):
timestamp = time.time()

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

# check that the request came in as a POST, or from the command line
if local.environ.get('REQUEST_METHOD', '') != 'POST':
@@ -268,8 +268,7 @@ class Board(object):
elif not admin_post_mode:
sticky = 0

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

username = accounttype = ''
@@ -277,7 +276,7 @@ class Board(object):
# check admin password - allow both encrypted and non-encrypted
if admin_post_mode:
username, accounttype = misc.check_password(admin, 'mpost')
admin_post = 'yes' # TODO use True/False?
admin_post = True
else:
if no_captcha or no_format or (sticky and not parent) or lock:
raise WakaError(strings.WRONGPASS)
@@ -302,8 +301,8 @@ class Board(object):

if lock:
if parent:
threadupdate = threadupdate.values(locked='yes')
lock = 'yes' # TODO use True/False?
threadupdate = threadupdate.values(locked=True)
lock = True

if (sticky or lock) and parent:
session.execute(threadupdate)
@@ -625,10 +624,7 @@ class Board(object):
if not width: # unsupported file
if ext in filetypes: # externally defined filetype
# Compensate for absolute paths, if given.
if filetypes[ext].startswith("/"):
icon = filetypes[ext][1:] # FIXME: wtf is wakaba doing here
else:
icon = os.path.join(self.path, filetypes[ext])
icon = os.path.join(self.path, filetypes[ext].lstrip("/"))

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


+ 1
- 3
crypto.py View File

@@ -8,9 +8,7 @@ def rc4(message, key, skip=256):
message = [ord(x) for x in message]

def swap(x, y):
temp = s[x]
s[x] = s[y]
s[y] = temp
s[x], s[y] = s[y], s[x]

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


+ 5
- 3
misc.py View File

@@ -4,6 +4,7 @@ import re
import time
import crypt
import struct
import strings
from subprocess import Popen, PIPE

import util
@@ -115,7 +116,7 @@ def compile_spam_checker(spam_files):

def spam_engine(trap_fields, spam_files):
def spam_screen():
raise util.WakaError("Anti-spam filters triggered.")
raise util.WakaError(strings.SPAM)

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

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

def copy_animation_file(pch, image_filename):
pass


+ 4
- 3
model.py View File

@@ -1,6 +1,6 @@
import config, config_defaults
from sqlalchemy import create_engine
from sqlalchemy import Table, Column, Integer, Text, String, MetaData
from sqlalchemy import Table, Column, Integer, Text, String, MetaData, Boolean
from sqlalchemy.orm import sessionmaker, mapper, scoped_session
from sqlalchemy.ext.declarative import declarative_base

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

_boards[name] = table


Loading…
Cancel
Save