minimal working
This commit is contained in:
20
app/__init__.py
Normal file
20
app/__init__.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from flask import Flask
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
import os
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
config_string = os.environ.get("FLASK_CONFIG", "config.DevelopmentConfig")
|
||||
app.config.from_object("config.DevelopmentConifg")
|
||||
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///app.db"
|
||||
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
|
||||
db = SQLAlchemy(model_class=Base)
|
||||
db.init_app(app)
|
||||
|
||||
from . import routes
|
||||
|
8
app/models.py
Normal file
8
app/models.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from sqlalchemy import Integer, String
|
||||
from app import db
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
class Reply(db.Model):
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
attendence: Mapped[bool]
|
||||
comment: Mapped[str]
|
30
app/routes.py
Normal file
30
app/routes.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from flask import render_template, request, redirect
|
||||
|
||||
from . import app, db
|
||||
from .models import Reply
|
||||
|
||||
@app.route("/", methods=["GET"])
|
||||
def index():
|
||||
return render_template("pages/index.html")
|
||||
|
||||
@app.route("/process-form", methods=["POST"])
|
||||
def process_form():
|
||||
form_data = request.form
|
||||
attendence = True if form_data["attendence"] == "yes" else False
|
||||
comment = form_data["comment"]
|
||||
reply = Reply(attendence=attendence, comment=comment)
|
||||
try:
|
||||
db.session.add(reply)
|
||||
db.session.commit()
|
||||
return redirect("/success")
|
||||
except Exception as e:
|
||||
return "fail"
|
||||
|
||||
@app.route("/success", methods=["GET"])
|
||||
def success():
|
||||
return render_template("pages/success.html")
|
||||
|
||||
@app.route("/results")
|
||||
def results():
|
||||
replies = db.session.execute(db.select(Reply)).scalars()
|
||||
return render_template("pages/results.html", replies=replies)
|
3
app/tasks.py
Normal file
3
app/tasks.py
Normal file
@@ -0,0 +1,3 @@
|
||||
def example_task(n: int) -> int:
|
||||
""" Example task"""
|
||||
return n**n
|
3
app/templates/includes/footer.html
Normal file
3
app/templates/includes/footer.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<footer>
|
||||
<hr>
|
||||
</footer>
|
18
app/templates/includes/form.html
Normal file
18
app/templates/includes/form.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<form method="POST" action="/process-form">
|
||||
<div class="form-choice">
|
||||
<label for="attendence">Prisutnost (Attendence)</label>
|
||||
<div class="form-checkbox">
|
||||
<input type="radio" name="attendence" id="attendence" value="yes">
|
||||
<p>Dolazim (I'll be there)</p>
|
||||
</div>
|
||||
<div class="form-checkbox">
|
||||
<input type="radio" name="attendence" id="attendence" value="no">
|
||||
<p>Ne dolazim (Won't be there)</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-textarea">
|
||||
<label for="comment">Pitanje ili komentar (Question or comment)</label>
|
||||
<textarea name="comment"></textarea>
|
||||
</div>
|
||||
<button>Posalji (Submit)</button>
|
||||
</form>
|
4
app/templates/includes/header.html
Normal file
4
app/templates/includes/header.html
Normal file
@@ -0,0 +1,4 @@
|
||||
<header>
|
||||
<h1>Dekonferencija v1.0</h1>
|
||||
<hr>
|
||||
</header>
|
14
app/templates/layouts/base.html
Normal file
14
app/templates/layouts/base.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/holiday.css@0.11.2" />
|
||||
<title>App</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
{% include "includes/header.html" %}
|
||||
{% block content %}{% endblock content %}
|
||||
{% include "includes/footer.html" %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
9
app/templates/pages/index.html
Normal file
9
app/templates/pages/index.html
Normal file
@@ -0,0 +1,9 @@
|
||||
{% extends "layouts/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<p>Dekonferencija je prva konferencija koju organizuje Decentrala,samoorganizovani kolektiv. Dekonferencija je mesto gde cemo imati predavanja, radionice, razmenjivati iskustva i ideje i druziti se.
|
||||
</p>
|
||||
</div>
|
||||
{% include "includes/form.html" %}
|
||||
{% endblock %}
|
22
app/templates/pages/results.html
Normal file
22
app/templates/pages/results.html
Normal file
@@ -0,0 +1,22 @@
|
||||
{% extends "layouts/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Prisustvo (Attendance)</td>
|
||||
<td>Komentar ili pitanje (Comment or question)</td>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for reply in replies %}
|
||||
<tr>
|
||||
<td>
|
||||
{{reply["attendence"]}}
|
||||
</td>
|
||||
<td>
|
||||
{{reply["comment"]}}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor%}
|
||||
</table>
|
||||
{% endblock %}
|
10
app/templates/pages/success.html
Normal file
10
app/templates/pages/success.html
Normal file
@@ -0,0 +1,10 @@
|
||||
{% extends "layouts/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<p>Hvala na prijavi! U medjuvrmenu mozete se prikljuciti diskusijama na forumu (forum.dmz.rs) ili XMPP grupi(decentrala@conference.dmz.rs).
|
||||
|
||||
Thanks for application! In meantime you can join forum(forum.dmz.rs) or XMPP group (decentrala@conference.dmz.rs)
|
||||
</p>
|
||||
</div>
|
||||
{% endblock %}
|
Reference in New Issue
Block a user