mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 09:10:00 +00:00
Fix cookies messing with cache
Change Display name to Torrent display name for clarity
This commit is contained in:
parent
4571b55fc9
commit
064c33ecf4
|
@ -13,6 +13,9 @@ app.config.from_object('config')
|
|||
# Database
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||
|
||||
# Don't refresh cookie each request
|
||||
app.config['SESSION_REFRESH_EACH_REQUEST'] = False
|
||||
|
||||
# Debugging
|
||||
if app.config['DEBUG']:
|
||||
app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False
|
||||
|
|
|
@ -124,9 +124,9 @@ class DisabledSelectField(SelectField):
|
|||
|
||||
|
||||
class EditForm(FlaskForm):
|
||||
display_name = TextField('Display name', [
|
||||
display_name = TextField('Torrent display name', [
|
||||
Length(min=3, max=255,
|
||||
message='Torrent name must be at least %(min)d characters and %(max)d at most.')
|
||||
message='Torrent display name must be at least %(min)d characters long and %(max)d at most.')
|
||||
])
|
||||
|
||||
category = DisabledSelectField('Category')
|
||||
|
@ -134,7 +134,7 @@ class EditForm(FlaskForm):
|
|||
def validate_category(form, field):
|
||||
cat_match = re.match(r'^(\d+)_(\d+)$', field.data)
|
||||
if not cat_match:
|
||||
raise ValidationError('You must select a category')
|
||||
raise ValidationError('Please select a category')
|
||||
|
||||
main_cat_id = int(cat_match.group(1))
|
||||
sub_cat_id = int(cat_match.group(2))
|
||||
|
@ -142,7 +142,7 @@ class EditForm(FlaskForm):
|
|||
cat = models.SubCategory.by_category_ids(main_cat_id, sub_cat_id)
|
||||
|
||||
if not cat:
|
||||
raise ValidationError('You must select a proper category')
|
||||
raise ValidationError('Please select a proper category')
|
||||
|
||||
field.parsed_data = cat
|
||||
|
||||
|
@ -169,10 +169,10 @@ class UploadForm(FlaskForm):
|
|||
FileRequired()
|
||||
])
|
||||
|
||||
display_name = TextField('Display name (optional)', [
|
||||
display_name = TextField('Torrent display name (optional)', [
|
||||
Optional(),
|
||||
Length(min=3, max=255,
|
||||
message='Torrent name must be at least %(min)d characters long and %(max)d at most.')
|
||||
message='Torrent display name must be at least %(min)d characters long and %(max)d at most.')
|
||||
])
|
||||
|
||||
# category = SelectField('Category')
|
||||
|
@ -181,7 +181,7 @@ class UploadForm(FlaskForm):
|
|||
def validate_category(form, field):
|
||||
cat_match = re.match(r'^(\d+)_(\d+)$', field.data)
|
||||
if not cat_match:
|
||||
raise ValidationError('You must select a category')
|
||||
raise ValidationError('Please select a category')
|
||||
|
||||
main_cat_id = int(cat_match.group(1))
|
||||
sub_cat_id = int(cat_match.group(2))
|
||||
|
@ -189,7 +189,7 @@ class UploadForm(FlaskForm):
|
|||
cat = models.SubCategory.by_category_ids(main_cat_id, sub_cat_id)
|
||||
|
||||
if not cat:
|
||||
raise ValidationError('You must select a proper category')
|
||||
raise ValidationError('Please select a proper category')
|
||||
|
||||
field.parsed_data = cat
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import config
|
|||
|
||||
import json
|
||||
import re
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
import ipaddress
|
||||
import os.path
|
||||
import base64
|
||||
|
@ -190,8 +190,12 @@ def before_request():
|
|||
return logout()
|
||||
|
||||
flask.g.user = user
|
||||
flask.session.permanent = True
|
||||
flask.session.modified = True
|
||||
|
||||
if not 'timeout' in flask.session or flask.session['timeout'] < datetime.now():
|
||||
print("hio")
|
||||
flask.session['timeout'] = datetime.now() + timedelta(days=7)
|
||||
flask.session.permanent = True
|
||||
flask.session.modified = True
|
||||
|
||||
if flask.g.user.status == models.UserStatusType.BANNED:
|
||||
return 'You are banned.', 403
|
||||
|
@ -348,6 +352,8 @@ def login():
|
|||
|
||||
flask.g.user = user
|
||||
flask.session['user_id'] = user.id
|
||||
flask.session.permanent = True
|
||||
flask.session.modified = True
|
||||
|
||||
return flask.redirect(redirect_url())
|
||||
|
||||
|
@ -388,6 +394,8 @@ def register():
|
|||
db.session.commit()
|
||||
flask.g.user = user
|
||||
flask.session['user_id'] = user.id
|
||||
flask.session.permanent = True
|
||||
flask.session.modified = True
|
||||
return flask.redirect(redirect_url())
|
||||
|
||||
return flask.render_template('register.html', form=form)
|
||||
|
@ -418,7 +426,6 @@ def profile():
|
|||
db.session.commit()
|
||||
|
||||
flask.g.user = user
|
||||
flask.session['user_id'] = user.id
|
||||
|
||||
return flask.render_template('profile.html', form=form)
|
||||
|
||||
|
|
Loading…
Reference in a new issue