From 9d5c153d8d38fff0991b8959ccff2ff094fd9776 Mon Sep 17 00:00:00 2001 From: Matthias Bilger Date: Sun, 21 Oct 2018 20:56:21 +0200 Subject: [PATCH] some comments --- infomentor/connector.py | 1 + infomentor/informer.py | 4 ++++ infomentor/model.py | 7 +++++++ infomentor/web.py | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 infomentor/web.py diff --git a/infomentor/connector.py b/infomentor/connector.py index 8bd2184..4ca2d9b 100644 --- a/infomentor/connector.py +++ b/infomentor/connector.py @@ -13,6 +13,7 @@ import uuid from infomentor import model class InfomentorFile(object): + '''Represent a file which is downloaded''' def __init__(self, directory, filename): if directory is None: raise Exception('directory is required') diff --git a/infomentor/informer.py b/infomentor/informer.py index 4a74c7a..f98f830 100755 --- a/infomentor/informer.py +++ b/infomentor/informer.py @@ -10,12 +10,16 @@ import pushover pushover.init('***REMOVED***') class Informer(object): + '''The Logic part of the infomentor notifier. + + This class offers the methods required to notify a user of new News and Homework items posted on infomentor.''' def __init__(self, user, im, logger): self.logger = logger or logging.getLogger(__name__) self.user = user self.im = im def send_status_update(self, text): + '''In case something unexpected happends and the user has activated the feature to get notified about it, this will send out the information''' try: if self.user.notification.ntype == model.Notification.Types.PUSHOVER: pushover.Client(self.user.notification.info).send_message( diff --git a/infomentor/model.py b/infomentor/model.py index 4990df4..72afc06 100755 --- a/infomentor/model.py +++ b/infomentor/model.py @@ -17,6 +17,7 @@ def unpad(s): return s[0:-s[-1]].decode('utf8') class User(ModelBase): + '''The infomentor user.''' __tablename__ = 'users' id = Column(Integer, primary_key=True) @@ -55,9 +56,11 @@ class User(ModelBase): class Notification(ModelBase): + '''This contains the information about the type of notification and additional the key to reach out to the user''' __tablename__ = 'notifications' class Types(enum.Enum): + '''Supported notification types''' PUSHOVER = 1 EMAIL = 2 @@ -73,6 +76,7 @@ class Notification(ModelBase): class Attachment(ModelBase): + '''General attachment type for homework and news''' __tablename__ = 'attachments' id = Column(Integer, primary_key=True) @@ -89,6 +93,7 @@ class Attachment(ModelBase): class News(ModelBase): + '''A News entry''' __tablename__ = 'news' id = Column(Integer, primary_key=True) @@ -110,6 +115,7 @@ class News(ModelBase): self.id, self.title) class Homework(ModelBase): + '''A homework entry''' __tablename__ = 'homework' id = Column(Integer, primary_key=True) @@ -124,6 +130,7 @@ class Homework(ModelBase): user = relationship("User", back_populates="homeworks") class ApiStatus(ModelBase): + '''Representing the result of the last trys to access the api, represented as one status''' __tablename__ = 'api_status' id = Column(Integer, primary_key=True) diff --git a/infomentor/web.py b/infomentor/web.py new file mode 100644 index 0000000..1b6c66b --- /dev/null +++ b/infomentor/web.py @@ -0,0 +1,18 @@ +from infomentor import models, db +from flask import Flask, render_template +from flask_bootstrap import Bootstrap + +app = Flask(__name__) +Bootstrap(app) + +@app.route('/') +def home(): + return render_template('notfound.html') + +@app.route('/addlogin/') +def extra(): + return render_template('addlogin.html') + +if __name__ == '__main__': + app.run(debug=True) +