Fix up A-Z stuff.
This commit is contained in:
parent
75a6844b9b
commit
237a671171
4
.gitignore
vendored
4
.gitignore
vendored
@ -3,10 +3,12 @@ __pycache__/
|
||||
*.py[cod]
|
||||
|
||||
*.so
|
||||
static/img/hero-images/*.png
|
||||
app/static/img/hero-images/
|
||||
|
||||
|
||||
# DOTANOOBS
|
||||
config.py
|
||||
venv/
|
||||
*.db
|
||||
*.swp
|
||||
clientlist.txt
|
||||
|
4
app.py
4
app.py
@ -1,13 +1,11 @@
|
||||
#!venv/bin/python
|
||||
import os
|
||||
from flask import Flask
|
||||
from flask.ext.script import Manager, Server
|
||||
from flask.ext.migrate import Migrate, MigrateCommand
|
||||
|
||||
from app import *
|
||||
|
||||
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'app.db')
|
||||
SQLALCHEMY_DATABASE_URI = 'mysql://root:$perwePP@localhost/dotanoobs'
|
||||
|
||||
migrate = Migrate(app, db)
|
||||
manager = Manager(app)
|
||||
|
@ -6,7 +6,7 @@ from sqlalchemy.ext.mutable import Mutable
|
||||
|
||||
import board
|
||||
from app import db, app
|
||||
from utils import parse_valve_heropedia, complete_hero_data
|
||||
from utils import parse_valve_heropedia, complete_hero_data, API_DATA
|
||||
|
||||
# Model independant get_or_create
|
||||
def get_or_create_instance(session, model, **kwargs):
|
||||
@ -73,6 +73,7 @@ class User(db.Model):
|
||||
last_seen = db.Column(db.DateTime)
|
||||
twitch = db.Column(db.String(60))
|
||||
random_heroes = db.Column(MutableDict.as_mutable(Json))
|
||||
az_completions = db.Column(db.Integer)
|
||||
|
||||
public = db.Column(db.Boolean)
|
||||
logo = db.Column(db.Boolean)
|
||||
@ -94,6 +95,7 @@ class User(db.Model):
|
||||
def __init__(self, steam_id):
|
||||
self.steam_id = steam_id
|
||||
self.random_heroes = {'current':None, 'completed':[]}
|
||||
self.az_completions = 0
|
||||
self.created = datetime.utcnow()
|
||||
self.last_seen = datetime.utcnow()
|
||||
self.bio_text = None
|
||||
@ -109,7 +111,7 @@ class User(db.Model):
|
||||
if not self.random_heroes['current']:
|
||||
heroes = []
|
||||
for (tavern_name, tavern) in parse_valve_heropedia():
|
||||
heroes.extend([complete_hero_data('name', entry['name']) for entry in tavern])
|
||||
heroes.extend([complete_hero_data('name', entry['name']) for entry in tavern if entry['name'] not in self.random_heroes['completed']])
|
||||
if heroes:
|
||||
self.random_heroes['current'] = choice(heroes)
|
||||
self.random_heroes = self.random_heroes
|
||||
@ -128,6 +130,9 @@ class User(db.Model):
|
||||
|
||||
def random_success(self):
|
||||
self.random_heroes['completed'].append(self.random_heroes['current']['name'])
|
||||
if len(API_DATA['result']['heroes']) - len(self.random_heroes['completed']) <= 0:
|
||||
self.az_completions = self.az_completions + 1
|
||||
del self.random_heroes['completed'][:]
|
||||
self.random_heroes['current'] = None
|
||||
self.random_heroes = self.random_heroes
|
||||
db.session.commit()
|
||||
|
@ -21,7 +21,7 @@
|
||||
</span>
|
||||
</p>
|
||||
|
||||
{% if g.user and g.user.steamid == user.steamid %}
|
||||
{% if g.user and g.user.steam_id == user.steam_id %}
|
||||
<form action="{{ url_for('user_random_hero', userid=g.user.id) }}" method="post" id="random_form" class="uk-margin">
|
||||
<input type="checkbox" name="completed" id="completed_checkbox" style="display:none;">
|
||||
<input type="checkbox" name="skip" id="skip_checkbox" style="display:none;">
|
||||
@ -31,7 +31,9 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="uk-width-large-2-3 uk-width-medium-1-1 uk-panel uk-text-center uk-margin">
|
||||
<div class="uk-badge uk-panel-badge uk-badge-notification uk-badge-success">x1</div>
|
||||
{% if user.az_completions > 0 %}
|
||||
<div class="uk-badge uk-panel-badge uk-badge-notification uk-badge-success">x{{ user.az_completions }}</div>
|
||||
{% endif %}
|
||||
<h3 class="uk-panel-title">Completed</h3>
|
||||
{% for hero in user.random_heroes.completed %}
|
||||
<img src="{{ url_for('static', filename=hero_image_small(hero)) }}" class="dn-hero-icon" />
|
||||
|
@ -1,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 23bfef078b06
|
||||
Revises: 47c81a0d0be7
|
||||
Create Date: 2014-06-22 18:04:41.935383
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '23bfef078b06'
|
||||
down_revision = '47c81a0d0be7'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('user', sa.Column('winrate_interval', sa.Integer(), nullable=True))
|
||||
op.add_column('user', sa.Column('winrate_map', sa.Boolean(), nullable=True))
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('user', 'winrate_map')
|
||||
op.drop_column('user', 'winrate_interval')
|
||||
### end Alembic commands ###
|
@ -1,13 +1,13 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 47c81a0d0be7
|
||||
Revision ID: a6f7dd522b7
|
||||
Revises: None
|
||||
Create Date: 2014-06-22 17:22:24.865474
|
||||
Create Date: 2014-06-22 22:35:25.691983
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '47c81a0d0be7'
|
||||
revision = 'a6f7dd522b7'
|
||||
down_revision = None
|
||||
|
||||
from alembic import op
|
||||
@ -16,25 +16,6 @@ import sqlalchemy as sa
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('event',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=200), nullable=True),
|
||||
sa.Column('desc', sa.String(length=4096), nullable=True),
|
||||
sa.Column('type', sa.String(length=20), nullable=True),
|
||||
sa.Column('start_time', sa.DateTime(), nullable=True),
|
||||
sa.Column('end_time', sa.DateTime(), nullable=True),
|
||||
sa.Column('points', sa.Integer(), nullable=True),
|
||||
sa.Column('reward_threshold', sa.Integer(), nullable=True),
|
||||
sa.Column('total_subchans', sa.Integer(), nullable=True),
|
||||
sa.Column('channels', sa.Json(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('teamspeak_data',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('time', sa.DateTime(), nullable=True),
|
||||
sa.Column('clients', sa.Json(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('user',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('steam_id', sa.String(length=40), nullable=True),
|
||||
@ -48,6 +29,7 @@ def upgrade():
|
||||
sa.Column('last_seen', sa.DateTime(), nullable=True),
|
||||
sa.Column('twitch', sa.String(length=60), nullable=True),
|
||||
sa.Column('random_heroes', sa.Json(), nullable=True),
|
||||
sa.Column('az_completions', sa.Integer(), nullable=True),
|
||||
sa.Column('public', sa.Boolean(), nullable=True),
|
||||
sa.Column('logo', sa.Boolean(), nullable=True),
|
||||
sa.Column('points_from_events', sa.Integer(), nullable=True),
|
||||
@ -62,12 +44,31 @@ def upgrade():
|
||||
sa.UniqueConstraint('steam_id'),
|
||||
sa.UniqueConstraint('teamspeak_id')
|
||||
)
|
||||
op.create_table('teamspeak_data',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('time', sa.DateTime(), nullable=True),
|
||||
sa.Column('clients', sa.Json(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('event',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=200), nullable=True),
|
||||
sa.Column('desc', sa.String(length=4096), nullable=True),
|
||||
sa.Column('type', sa.String(length=20), nullable=True),
|
||||
sa.Column('start_time', sa.DateTime(), nullable=True),
|
||||
sa.Column('end_time', sa.DateTime(), nullable=True),
|
||||
sa.Column('points', sa.Integer(), nullable=True),
|
||||
sa.Column('reward_threshold', sa.Integer(), nullable=True),
|
||||
sa.Column('total_subchans', sa.Integer(), nullable=True),
|
||||
sa.Column('channels', sa.Json(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('user')
|
||||
op.drop_table('teamspeak_data')
|
||||
op.drop_table('event')
|
||||
op.drop_table('teamspeak_data')
|
||||
op.drop_table('user')
|
||||
### end Alembic commands ###
|
@ -181,10 +181,12 @@ def award_idle_ts3_points(server, cfg):
|
||||
doob.update_connection()
|
||||
active_users.add(doob)
|
||||
doobs = set(models.User.query.filter(models.User.ts3_starttime != None).all())
|
||||
'''
|
||||
print doobs, active_users
|
||||
for doob in doobs.intersection(active_users):
|
||||
print(doob.nickname)
|
||||
#doob.finalize_connection()
|
||||
doob.finalize_connection()
|
||||
'''
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user