aboutsummaryrefslogtreecommitdiff
path: root/cgi
diff options
context:
space:
mode:
Diffstat (limited to 'cgi')
-rw-r--r--cgi/manage.py185
1 files changed, 143 insertions, 42 deletions
diff --git a/cgi/manage.py b/cgi/manage.py
index 064b0cf..4199b91 100644
--- a/cgi/manage.py
+++ b/cgi/manage.py
@@ -852,110 +852,200 @@ def manage(self, path_split):
if len(path_split) > 3:
board = setBoard(path_split[3])
form_submitted = False
+
try:
if self.formdata['name'] != '':
form_submitted = True
except:
pass
+
if form_submitted:
+ rebuild = 0
+
# Update board settings
- board['name'] = self.formdata['name']
- board['longname'] = self.formdata['longname']
- board['subname'] = self.formdata['subname']
+
+ if self.formdata['longname'] != board['longname']:
+ board['longname'] = self.formdata['longname']
+ if board['board_type'] == 1:
+ rebuild |= 1
+ else:
+ rebuild |= 2
+
+ if board['name'] != self.formdata['name']:
+ board['name'] = self.formdata['name']
+ rebuild |= 2
+ if board['board_type'] == 1:
+ rebuild |= 4
+
+ if board['subname'] != self.formdata['subname']:
+ board['subname'] = self.formdata['subname']
+ rebuild |= 8
+
board['anonymous'] = self.formdata['anonymous']
board['subject'] = self.formdata['subject']
board['message'] = self.formdata['message']
+
board['useid'] = self.formdata['useid']
board['slip'] = self.formdata['slip']
board['countrycode'] = self.formdata['countrycode']
+
if 'recyclebin' in self.formdata:
board['recyclebin'] = 1
else:
board['recyclebin'] = 0
- if 'disable_name' in self.formdata:
+
+ if 'disable_name' in self.formdata and not board['disable_name']:
board['disable_name'] = 1
- else:
+ if board['board_type'] == 0:
+ rebuild |= 2
+ elif 'disable_name' not in self.formdata and board['disable_name']:
board['disable_name'] = 0
- if 'disable_subject' in self.formdata:
+ if board['board_type'] == 0:
+ rebuild |= 2
+
+ if 'disable_subject' in self.formdata and not board['disable_subject']:
board['disable_subject'] = 1
- else:
+ if board['board_type'] == 0:
+ rebuild |= 2
+ elif 'disable_subject' not in self.formdata and board['disable_subject']:
board['disable_subject'] = 0
+ if board['board_type'] == 0:
+ rebuild |= 2
+
if 'secret' in self.formdata:
board['secret'] = 1
else:
board['secret'] = 0
+
if 'locked' in self.formdata:
board['locked'] = 1
else:
board['locked'] = 0
- board['postarea_desc'] = self.formdata['postarea_desc']
- if 'allow_noimage' in self.formdata:
+
+ if board['postarea_desc'] != self.formdata['postarea_desc']:
+ board['postarea_desc'] = self.formdata['postarea_desc']
+ if board['board_type'] == 1:
+ rebuild |= 1
+ else:
+ rebuild |= 2
+
+ if board['postarea_extra'] != self.formdata['postarea_extra']:
+ board['postarea_extra'] = self.formdata['postarea_extra']
+ if board['board_type'] == 1:
+ rebuild |= 1
+ else:
+ rebuild |= 2
+
+ if board['force_css'] != self.formdata['force_css']:
+ board['force_css'] = self.formdata['force_css']
+ rebuild |= 2
+
+ if 'allow_noimage' in self.formdata and not board['allow_noimage']:
board['allow_noimage'] = 1
- else:
+ if board['board_type'] == 0:
+ rebuild |= 2
+ elif 'allow_noimage' not in self.formdata and board['allow_noimage']:
board['allow_noimage'] = 0
- if 'allow_images' in self.formdata:
+ if board['board_type'] == 0:
+ rebuild |= 2
+
+ if 'allow_images' in self.formdata and not board['allow_images']:
board['allow_images'] = 1
- else:
+ rebuild |= 1
+ elif 'allow_images' not in self.formdata and board['allow_images']:
board['allow_images'] = 0
- if 'allow_image_replies' in self.formdata:
+ rebuild |= 1
+
+ if 'allow_image_replies' in self.formdata and not board['allow_image_replies']:
board['allow_image_replies'] = 1
- else:
+ rebuild |= 2
+ elif 'allow_image_replies' not in self.formdata and board['allow_image_replies']:
board['allow_image_replies'] = 0
- if 'allow_spoilers' in self.formdata:
+ rebuild |= 2
+
+ if 'allow_spoilers' in self.formdata and not board['allow_spoilers']:
board['allow_spoilers'] = 1
- else:
+ if board['board_type'] == 0:
+ rebuild |= 2
+ elif 'allow_spoilers' not in self.formdata and board['allow_spoilers']:
board['allow_spoilers'] = 0
- if 'allow_oekaki' in self.formdata:
+ if board['board_type'] == 0:
+ rebuild |= 2
+
+ if 'allow_oekaki' in self.formdata and not board['allow_oekaki']:
board['allow_oekaki'] = 1
- else:
+ if board['board_type'] == 0:
+ rebuild |= 2
+ elif 'allow_oekaki' not in self.formdata and board['allow_oekaki']:
board['allow_oekaki'] = 0
+ if board['board_type'] == 0:
+ rebuild |= 2
+
if 'archive' in self.formdata:
board['archive'] = 1
else:
board['archive'] = 0
- board['postarea_extra'] = self.formdata['postarea_extra']
- board['force_css'] = self.formdata['force_css']
-
- # Update file types
- UpdateDb(
- "DELETE FROM `boards_filetypes` WHERE `boardid` = %s" % board['id'])
- for filetype in filetypelist():
- if 'filetype'+filetype['ext'] in self.formdata:
- UpdateDb("INSERT INTO `boards_filetypes` VALUES (%s, %s)" % (
- board['id'], filetype['id']))
+ # update file types
+ new_filetypes = [(ft.replace('filetype', '')) for ft in self.formdata if ft.startswith('filetype')]
+ if sorted(board['filetypes_ext']) != sorted(new_filetypes):
+ UpdateDb("DELETE FROM boards_filetypes WHERE boardid = %s", (board['id'],) )
+ for filetype in filetypelist():
+ if 'filetype'+filetype['ext'] in self.formdata:
+ UpdateDb("INSERT INTO boards_filetypes VALUES (%s, %s)", (board['id'], filetype['id']) )
+ if board['board_type'] == 0:
+ rebuild |= 2
+
try:
- board['numthreads'] = int(self.formdata['numthreads'])
+ if board['numthreads'] != int(self.formdata['numthreads']):
+ board['numthreads'] = int(self.formdata['numthreads'])
+ rebuild |= 1
except:
raise UserError(_("Max threads shown must be numeric."))
try:
- board['numcont'] = int(self.formdata['numcont'])
+ if board['numcont'] != int(self.formdata['numcont']):
+ board['numcont'] = int(self.formdata['numcont'])
+ rebuild |= 1
except:
raise UserError(_("Max replies shown must be numeric."))
try:
- board['numline'] = int(self.formdata['numline'])
+ if board['numline'] != int(self.formdata['numline']):
+ board['numline'] = int(self.formdata['numline'])
+ rebuild |= 1
except:
raise UserError(_("Max lines shown must be numeric."))
try:
- board['thumb_px'] = int(self.formdata['thumb_px'])
+ if board['thumb_px'] != int(self.formdata['thumb_px']):
+ board['thumb_px'] = int(self.formdata['thumb_px'])
+ if board['board_type'] == 0:
+ rebuild |= 2
except:
raise UserError(_("Max thumb dimensions must be numeric."))
try:
- board['maxsize'] = int(self.formdata['maxsize'])
+ if board['maxsize'] != int(self.formdata['maxsize']):
+ board['maxsize'] = int(self.formdata['maxsize'])
+ if board['board_type'] == 0:
+ rebuild |= 2
except:
raise UserError(_("Max size must be numeric."))
try:
- board['maxage'] = int(self.formdata['maxage'])
+ if board['maxage'] != int(self.formdata['maxage']):
+ board['maxage'] = int(self.formdata['maxage'])
+ if board['board_type'] == 0:
+ rebuild |= 2
except:
raise UserError(_("Max age must be numeric."))
try:
- board['maxinactive'] = int(self.formdata['maxinactive'])
+ if board['maxinactive'] != int(self.formdata['maxinactive']):
+ board['maxinactive'] = int(self.formdata['maxinactive'])
+ if board['board_type'] == 0:
+ rebuild |= 2
except:
raise UserError(_("Max inactivity must be numeric."))
@@ -976,17 +1066,28 @@ def manage(self, path_split):
updateBoardSettings()
- message = _('Board options successfully updated.') + ' <a href="' + \
- Settings.CGI_URL+'manage/rebuild/' + \
- board['dir']+'">'+_('Rebuild')+'</a>'
+ board = setBoard(board['dir'])
+ if rebuild & 2:
+ regenerateBoard(everything=True)
+ elif rebuild & 1:
+ regenerateBoard()
+
+ if rebuild & 4:
+ regenerateKako()
+
+ if rebuild & 8:
+ regenerateHome()
+
+ message = _('Board options successfully updated.')
template_filename = "message.html"
- logAction(staff_account['username'], _(
- 'Updated options for /%s/') % board['dir'])
+ logAction(staff_account['username'], _('Updated options for /%s/') % board['dir'])
else:
template_filename = "boardoptions.html"
- template_values = {'mode': 1, 'boardopts': board, 'filetypes': filetypelist(
- ), 'supported_filetypes': board['filetypes_ext']}
+ template_values = { 'mode': 1,
+ 'boardopts': board,
+ 'filetypes': filetypelist(),
+ 'supported_filetypes': board['filetypes_ext'] }
else:
# List all boards
template_filename = "boardoptions.html"