some comments
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
|
||||
18
infomentor/web.py
Normal file
18
infomentor/web.py
Normal file
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user