Commit 762fba2e authored by Roman Shishkin's avatar Roman Shishkin

Ничего не успеваем

parent f9a2c473
......@@ -29,6 +29,6 @@ class Photo(db.Entity):
class User(db.Entity):
vk_id = orm.Required(int, unique=True)
balance = orm.Optional(int, sql_default=0)
balance = orm.Optional(int, sql_default='0')
photos = orm.Set("Photo")
posts = orm.Set("Post")
......@@ -29,7 +29,10 @@
<!-- Пользователь -->
<div class="row user-row">
<div class="user-row__avatar"><img src="{{user.photo_50}}"></div>
<div class="user-row__name">{{user.first_name}} {{user.last_name}}</div>
<div class="user-row__block">
<div class="user-row__name">{{user.first_name}} {{user.last_name}}</div>
<div class="user-row__balance">Баланс: {{user_balance}} баллов</div>
</div>
</div>
<!-- Меню -->
<div class="row">
......
......@@ -21,5 +21,5 @@ def check_user(app_id, viewer_id, app_secret, hash):
def get_user_from_db(vk_id):
user = User.get(vk_id=vk_id)
if user is None:
user = User(vk_id=vk_id)
user = User(vk_id=vk_id, balance=0)
return user
from flask import render_template, request, redirect, url_for, g
from ..utils import check_user, get_user_from_db
from ..models import User
from vklancer import api
def init(app):
......@@ -27,7 +28,8 @@ def init(app):
return render_template('error.html')
vk = api.API()
user = vk.users.get(user_ids=id, fields='has_photo,photo_50')
return render_template('submit.html', id=id, key=key, user=user['response'][0])
usr = get_user_from_db(id)
return render_template('submit.html', id=id, key=key, user=user['response'][0], user_balance=usr.balance)
@app.route('/admin/<int:id>/<string:key>')
def admin(id, key):
......@@ -41,13 +43,13 @@ def init(app):
return render_template('error.html')
return render_template('editor.html', id=id, key=key)
if app.config['DEBUG']:
@app.route('/submit')
def submit_dev():
vk = api.API()
user = vk.users.get(user_ids=1, fields='has_photo,photo_50')
return render_template('submit.html', id=1, key='d666f7eddb8aa15092c48c64bff6c7d4', user=user['response'][0])
usr = get_user_from_db(1)
return render_template('submit.html', id=1, key='d666f7eddb8aa15092c48c64bff6c7d4', user=user['response'][0], user_balance=usr.balance)
@app.route('/admin')
def admin_dev():
......
......@@ -18,13 +18,12 @@
Ссылки (не более 5): <a class="btn btn-xs btn-primary addfields" ng-click="addNewChoice()">Добавить поле</a>
</label>
<fieldset data-ng-repeat="choice in choices">
<input type="text" class="form-control" ng-model="choice.url" name="" placeholder="Введите адрес ссылки" style="width: 90%">
<button class="btn btn-danger btn-small remove" ng-show="$last" ng-click="removeChoice()">-</button>
<input type="text" class="form-control" ng-model="choice.url" name="" pattern="https?://.+" placeholder="Введите адрес ссылки" style="width: 90%">
<a class="btn btn-danger btn-small remove" ng-show="$last" ng-click="removeChoice()">-</a>
</fieldset>
</div>
<div class="input-group">
<label for="text">
Текст новости:
</label>
......
......@@ -35,11 +35,17 @@ label {
padding: 6px;
display: inline-block;
}
.user-row__name {
.user-row__block {
display: inline-block;
vertical-align: middle;
}
.user-row__name {
font-size: 16pt;
font-weight: bold;
vertical-align: middle;
vertical-align: top;
}
.user-row__balance {
font-size: 14pt;
}
.image-list {
......
......@@ -48,34 +48,6 @@ containers:
environ:
ECHOES_CONFIG: localConfig.LocalDevelopment
redis:
setup:
- !Container _base_alpine
- !Install [redis]
- !EnsureDir /storage
volumes:
<<: *local_volumes
/storage: !Tmpfs
size: 128Mi
mode: 0o1700
celery:
setup:
- !Container _base_alpine
- !Install [python3]
- !PipConfig
dependencies: true
- !Py3Install
- celery[redis]
- numpy
- !EnsureDir /app
volumes:
<<: *local_volumes
/app: !BindRO /work/celery_tasks
environ:
PYTHONPATH: /config/celeryconfig:/app
CELERY_CONFIG_MODULE: cfg
# Production containers
frontend-production:
setup:
......@@ -135,52 +107,12 @@ containers:
resolv-conf-path: /state/resolv.conf
hosts-file-path: /state/hosts
redis-production:
setup:
- !Container redis
- !*Unpack
- *production_stuff
- *host_resolution
resolv-conf-path: /state/resolv.conf
hosts-file-path: /state/hosts
celery-production:
setup:
- !Container celery
- !*Unpack
- *production_stuff
- *host_resolution
- !Copy
source: /work/celery_tasks
path: /app
- !Sh python3 -m compileall /app
resolv-conf-path: /state/resolv.conf
hosts-file-path: /state/hosts
commands:
flask: &flask !Command
container: python
description: Run flask app
run: [python3, run.py]
redis-cli: &redis !Command
container: redis
description: Run redis CLI
run: [redis-cli]
redis: &redis !Command
container: redis
description: Run redis server (cache and broker for celery)
run: redis-server /config/redis.conf
celery: &celery !Command
container: celery
description: Run celery worker for async tasks
user-id: 1
group-id: 1
external-user-id: 0
run: celery worker --pool=solo
init_db: !Command
container: python
description: Init database
......@@ -209,10 +141,4 @@ commands:
description: Run full server stack
kill-unresponsive-after: 5
children:
flask: *flask
redis: *redis
celery: *celery
semantics_example: !Command
container: python
run: [python3, echoes/memantic/__init__.py]
flask: *flask
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment