diff --git a/app.py b/app.py
index 4c2b06e..779c7ea 100644
--- a/app.py
+++ b/app.py
@@ -89,7 +89,10 @@ csrf.exempt('search_quotes')
csrf.exempt('get_stats')
# Initialize rate limiter with custom IP detection
-limiter = Limiter(app, key_func=get_real_ip)
+limiter = Limiter(
+ key_func=get_real_ip,
+ app=app
+)
db = SQLAlchemy(app)
@@ -164,8 +167,8 @@ def submit():
# Input validation and length limits from config
quote_text = quote_text.strip()
- min_length = config.min_quote_length
- max_length = config.max_quote_length
+ min_length = config.get('quotes.min_length', 10)
+ max_length = config.get('quotes.max_length', 5000)
if len(quote_text) < min_length:
flash(f"Your quote is too short. Please enter at least {min_length} characters.", 'error')
@@ -184,14 +187,32 @@ def submit():
ip_address = get_real_ip() # Get the real user's IP address
user_agent = request.headers.get('User-Agent') # Get the user's browser info
- new_quote = Quote(text=quote_text, ip_address=ip_address, user_agent=user_agent)
+ # Determine initial status based on config
+ auto_approve = config.get('quotes.auto_approve', False)
+ initial_status = 1 if auto_approve else 0 # 1 = approved, 0 = pending
+
+ new_quote = Quote(
+ text=quote_text,
+ ip_address=ip_address,
+ user_agent=user_agent,
+ status=initial_status
+ )
try:
db.session.add(new_quote)
db.session.commit()
- flash("Thanks! Your quote has been submitted and is awaiting approval by our moderators.", 'success')
+
+ # Log the quote creation for debugging
+ if config.get('logging.level') == 'DEBUG':
+ print(f"Quote created: ID={new_quote.id}, Status={new_quote.status}, Text='{quote_text[:50]}...'")
+
+ if auto_approve:
+ flash("Thanks! Your quote has been submitted and automatically approved.", 'success')
+ else:
+ flash("Thanks! Your quote has been submitted and is awaiting approval by our moderators.", 'success')
except Exception as e:
db.session.rollback()
+ print(f"Error submitting quote: {e}") # Always log errors
flash("Sorry, something went wrong while submitting your quote. Please try again in a moment.", 'error')
return redirect(url_for('index'))
diff --git a/config.json b/config.json
index c240550..84a8ce9 100644
--- a/config.json
+++ b/config.json
@@ -59,7 +59,7 @@
"password_hash": "$argon2i$v=19$m=65536,t=4,p=1$cWZDc1pQaUJLTUJoaVI4cw$kn8XKz6AEZi8ebXfyyZuzommSypliVFrsGqzOyUEIHA"
},
"quotes": {
- "min_length": 10,
+ "min_length": 1,
"max_length": 5000,
"per_page": 25,
"auto_approve": false,
@@ -74,7 +74,7 @@
"bulk_moderation_enabled": true
},
"logging": {
- "level": "WARNING",
+ "level": "DEBUG",
"format": "%(asctime)s [%(levelname)s] %(message)s"
}
}
\ No newline at end of file
diff --git a/instance/quotes.db b/instance/quotes.db
index d97b86c..971da4d 100644
Binary files a/instance/quotes.db and b/instance/quotes.db differ
diff --git a/templates/browse.html b/templates/browse.html
index 705d12d..4898630 100644
--- a/templates/browse.html
+++ b/templates/browse.html
@@ -111,7 +111,7 @@
Hosted by YourHostingProvider
- © ircquotes 2024, All Rights Reserved.
+ @ ircquotes 2024-2025
diff --git a/templates/index.html b/templates/index.html
index fdf229a..ba6ca31 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -85,7 +85,7 @@
-
© ircquotes 2024, All Rights Reserved.
+
@ ircquotes 2024-2025