main
parent
a5317978af
commit
20f92bd763
Binary file not shown.
Binary file not shown.
23
main.py
23
main.py
|
@ -17,7 +17,7 @@ app = Flask(__name__)
|
|||
app.secret_key = 'bebra'
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///Picture_Puzzle_web.db'
|
||||
app.config['UPLOAD_FOLDER'] = 'uploads'
|
||||
app.config['ALLOWED_EXTENSIONS'] = {'png', 'jpg', 'jpeg', 'gif', 'mp4', 'waw'}
|
||||
app.config['ALLOWED_EXTENSIONS'] = {'png', 'jpg', 'jpeg', 'gif', 'mp4', 'waw', 'pdf'}
|
||||
db = SQLAlchemy(app)
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
class User(db.Model):
|
||||
|
@ -58,11 +58,10 @@ class ForumComment(db.Model):
|
|||
post_id = db.Column(db.Integer, db.ForeignKey('forumpost.id'), nullable=False)
|
||||
created_by = db.Column(db.String(100), nullable=False)
|
||||
creation_date = db.Column(db.DateTime, nullable=False)
|
||||
media = db.Column(db.Integer) # Assuming 'media' is a column containing media IDs
|
||||
media = db.Column(db.Integer)
|
||||
text = db.Column(db.Text, nullable=False)
|
||||
edited = db.Column(db.Boolean, default=False)
|
||||
|
||||
# Define a primaryjoin expression
|
||||
post = relationship("ForumPost", primaryjoin="foreign(ForumComment.post_id) == remote(ForumPost.id)")
|
||||
|
||||
class Media(db.Model):
|
||||
|
@ -78,6 +77,7 @@ class CreatePostForm(FlaskForm):
|
|||
text = TextAreaField('Post Content', validators=[InputRequired()])
|
||||
media = FileField('Insert Media', validators=[FileAllowed(app.config['ALLOWED_EXTENSIONS'])])
|
||||
|
||||
|
||||
def admin_login_required(view_func):
|
||||
@wraps(view_func)
|
||||
def decorated_function(*args, **kwargs):
|
||||
|
@ -239,13 +239,11 @@ def create_post(category_id):
|
|||
form = CreatePostForm()
|
||||
category = ForumCategory.query.get_or_404(category_id)
|
||||
|
||||
# Provide choices for category_id field
|
||||
form.category_id.choices = [(category.id, category.category_name) for category in ForumCategory.query.all()]
|
||||
|
||||
if form.validate_on_submit():
|
||||
post_name = form.post_name.data
|
||||
created_by = form.created_by.data
|
||||
text = form.text.data
|
||||
if request.method == 'POST':
|
||||
post_name = request.form['post_name']
|
||||
text = request.form['text']
|
||||
media_files = request.files.getlist('media')
|
||||
|
||||
media_filenames = []
|
||||
|
@ -255,10 +253,14 @@ def create_post(category_id):
|
|||
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
|
||||
media_filenames.append(filename)
|
||||
|
||||
user_nickname = None
|
||||
if g.user:
|
||||
user_nickname = g.user.username
|
||||
|
||||
new_post = ForumPost(
|
||||
category_id=category_id,
|
||||
post_name=post_name,
|
||||
created_by=created_by,
|
||||
created_by=user_nickname,
|
||||
text=text,
|
||||
creation_date=datetime.now(),
|
||||
edited=False
|
||||
|
@ -272,10 +274,11 @@ def create_post(category_id):
|
|||
|
||||
db.session.commit()
|
||||
|
||||
return redirect(url_for('category', category_id=category_id))
|
||||
return redirect(url_for('category', category_name=category.category_name.lower()))
|
||||
|
||||
return render_template('create_post.html', form=form, category=category)
|
||||
|
||||
|
||||
@app.route('/forums/<int:post_id>', methods=['GET', 'POST'])
|
||||
def view_post(post_id):
|
||||
post = ForumPost.query.get_or_404(post_id)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<div class="card-body">
|
||||
<div class="list-group">
|
||||
{% for post in posts %}
|
||||
<a href="{{ url_for('new_post', post_id=post.id) }}" class="list-group-item list-group-item-action">
|
||||
<a href="{{ url_for('view_post', post_id=post.id) }}" class="list-group-item list-group-item-action">
|
||||
<h5 class="mb-1">{{ post.post_name }}</h5>
|
||||
<p class="mb-1">{{ post.text }}</p>
|
||||
<small>Created by {{ post.created_by }} - {{ post.creation_date }}</small>
|
||||
|
|
|
@ -81,7 +81,8 @@
|
|||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h1>Create a New Post</h1>
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
<form method="POST" action="{{ url_for('create_post', category_id=category.id) }}" enctype="multipart/form-data">
|
||||
{{ form.csrf_token }}
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" id="post_name" name="post_name" placeholder="Title" required>
|
||||
</div>
|
||||
|
@ -95,6 +96,7 @@
|
|||
<ul id="file-list" class="file-list"></ul>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
|
||||
<p class="note"><strong>Note:</strong> **bold** for bold text, *italic* for italic text</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
<section class="content">
|
||||
<h1>Design and music making</h1>
|
||||
<img src="{{ url_for('static', filename='images/design-and-music.png') }}" alt="ruDALL-E generated image" width="800" height="500">
|
||||
<p class="text"></br>Design and music making process was sometimes interesting or quick and other times quite time-consuming.</p>
|
||||
<p class="text"></br>Design and music making process was sometimes interesting or quick and other times quite time-consuming. Many of the early design choices were scrapped completely, while some parts were remade to be more suitable for the game’s style.</br></br>
|
||||
While the original Picture Puzzle widget was semi-realistic to match the overall Windows app style, the idea for the remake’s design choice came mostly from the goal to make the game work faster and smoother, as well as the fact that pixel sprites are often easier to animate and take up much less space than HD sprites.
|
||||
</p>
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
<section class="content">
|
||||
<h1>Picture Puzzle history</h1>
|
||||
<img src="{{ url_for('static', filename='images/picture-puzzle.png') }}" alt="Picture Puzzle original" width="800" height="500">
|
||||
<p class="text"></br>The widgets originated in the Sideshow project at Microsoft Research. Its development started in the summer of 2000 and lasted for 1 year under the Microsoft brand.</p>
|
||||
<p class="text"></br>The widgets originated in the Sideshow project at Microsoft Research. Its development started in the summer of 2000 and lasted for 1 year under the Microsoft brand. In 2001, Picture Puzzle was released for Windows Vista, and then later was included in Windows 7 upon its release. Just like all the other gadgets, Picture Puzzle was quite popular as a form of a fun and interactive way for users to enjoy their favorite images while challenging their puzzle-solving skills.</br></br>Sadly, rumors started to spread about the malicious potential gadgets had, as most gadgets were created by third-party developers, which could result in malware being coded into the gadgets. Because of that, shortly after Windows 7 release Microsoft had officially announced the removal of gadgets.</br></br></br>
|
||||
womp womp
|
||||
</p>
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue