Browse Source

added image for mouse over feature

aguryev 3 years ago
parent
commit
e73c577d6a
6 changed files with 106 additions and 3 deletions
  1. 1 0
      app.py
  2. 8 1
      endpoints/routes.py
  3. BIN
      media/images/human_body.jpg
  4. 43 0
      pms/data/antrags.json
  5. 8 2
      populate_db.py
  6. 46 0
      populate_gamification_tables.py

+ 1 - 0
app.py

@@ -24,6 +24,7 @@ class Config(object):
     MEDIA = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'media')
     LOGO = os.path.join(MEDIA, 'logo')
     BADGES = os.path.join(MEDIA, 'badges')
+    IMAGES = os.path.join(MEDIA, 'images')
 
     PDF = str(Path(os.path.abspath(__file__)).parent.joinpath("pdfoutput"))
 

+ 8 - 1
endpoints/routes.py

@@ -62,7 +62,14 @@ def badge_image(type, level=None):
 @bp.route('/files/<string:filename>')
 def downloads(filename):
     path_to_file = os.path.join(current_app.config['PDF'], filename)
-    #print(path_to_file)
+    return send_file(
+        path_to_file,
+        attachment_filename=filename,
+    )
+
+@bp.route('/images/<string:filename>')
+def images(filename):
+    path_to_file = os.path.join(current_app.config['IMAGES'], filename)
     return send_file(
         path_to_file,
         attachment_filename=filename,

BIN
media/images/human_body.jpg


File diff suppressed because it is too large
+ 43 - 0
pms/data/antrags.json


+ 8 - 2
populate_db.py

@@ -2,8 +2,8 @@
 # create default user in PoLZy DB
 #
 
-from polzybackend.models import User, Role, Company, UserToCompany, CompanyToCompany, \
-    GamificationEvent, GamificationBadgeLevel, GamificationBadgeType, GamificationBadge, GamificationBadgeDescription
+from polzybackend.models import User, Role, Company, UserToCompany, CompanyToCompany#, \
+#    GamificationEvent, GamificationBadgeLevel, GamificationBadgeType, GamificationBadge, GamificationBadgeDescription
 from random import sample, choice
 from polzybackend.utils.auth_utils import generate_token
 import uuid
@@ -17,7 +17,10 @@ app = create_app(Config)
 db = SQLAlchemy(app)
 print(db)
 
+
 # Gamification Badges
+#### replaced by populate_gamification tables.py ####
+'''
 print('Creating Gamification Badges...')
 badge_levels = [
     "Bronze",
@@ -48,6 +51,7 @@ db.session.add_all([
         description=f"Requirements to earn {level.name} Badge {type.title}",
     ) for level in levels for type in types]
 )
+'''
 
 # create roles
 print('Creating roles...')
@@ -137,6 +141,7 @@ db.session.add(organization_agent)
 db.session.add(organization_clerk)
 
 # add badges
+'''
 user_badge_num = 10
 db.session.add_all([
     GamificationBadge(
@@ -146,6 +151,7 @@ db.session.add_all([
         level=choice(levels),
     ) for _ in sample(range(total_badge_number), user_badge_num)
 ])
+'''
 
 company = Company(
     name="SportIns",

+ 46 - 0
populate_gamification_tables.py

@@ -0,0 +1,46 @@
+from polzybackend.models import GamificationBadgeLevel, GamificationBadgeType, GamificationBadgeDescription
+from flask_sqlalchemy import SQLAlchemy
+from polzybackend import create_app
+from app import Config
+
+app = create_app(Config)
+db = SQLAlchemy(app)
+
+print('Creating Gamification Badges...')
+badge_levels = [
+    ("Greenhorn", 0),
+    ("Bronze", 10),
+    ("Silver", 50),
+    ("Gold", 100),
+    ("Platinum", 500)
+]
+levels = []
+next_level = None
+for name, point in reversed(badge_levels):
+    level = GamificationBadgeLevel(name=name, min_level=point, next_level=next_level, is_lowest=(name == 'Bronze'))
+    levels.append(level)
+    next_level = level
+
+db.session.add_all(levels)
+
+type_names = ["Antrag", "Polizze"]
+#lobs = [LineOfBusiness.KFZ, LineOfBusiness.PnC, LineOfBusiness.KV, LineOfBusiness.Life, LineOfBusiness.UV]
+lobs = ['Automobile']
+types = []
+
+for lob in lobs:
+    for type_name in type_names:
+        name = type_name + " " + lob
+        types.append(GamificationBadgeType(name=name, title=name))
+types.append(GamificationBadgeType(name="Login", title="Login"))
+db.session.add_all(types)
+
+db.session.add_all([
+    GamificationBadgeDescription(
+        level=level,
+        type=type,
+        description=f"Requirements to earn {level.name} Badge {type.title}",
+    ) for level in levels for type in types]
+)
+
+db.session.commit()