Преглед на файлове

randomly order resources when on regular view

joel
Simon Bowie преди 1 година
родител
ревизия
55671f78ac
променени са 3 файла, в които са добавени 6 реда и са изтрити 3 реда
  1. +2
    -1
      web/app/book.py
  2. +2
    -1
      web/app/practice.py
  3. +2
    -1
      web/app/tool.py

+ 2
- 1
web/app/book.py Целия файл

@@ -13,6 +13,7 @@ from .resources import *
from .relationships import *
from . import db
import os
from sqlalchemy.sql import func

book = Blueprint('book', __name__)

@@ -21,7 +22,7 @@ book = Blueprint('book', __name__)
def get_books():
view = request.args.get('view')
resource_type = 'book'
books_query = Resource.query.filter_by(type=resource_type)
books_query = Resource.query.filter_by(type=resource_type).order_by(func.random())
for key in request.args.keys():
if key != 'view':
if (key == 'practice' and request.args.get(key) != ''):

+ 2
- 1
web/app/practice.py Целия файл

@@ -14,6 +14,7 @@ from .relationships import *
from . import db
import os
import markdown
from sqlalchemy.sql import func

practice = Blueprint('practice', __name__)

@@ -21,7 +22,7 @@ practice = Blueprint('practice', __name__)
@practice.route('/practices')
def get_practices():
view = request.args.get('view')
practices = Resource.query.filter_by(type='practice').all()
practices = Resource.query.filter_by(type='practice').order_by(func.random()).all()
# get number of practices
count = len(practices)
if view != 'list':

+ 2
- 1
web/app/tool.py Целия файл

@@ -13,6 +13,7 @@ from .resources import *
from .relationships import *
from . import db
import os
from sqlalchemy.sql import func

tool = Blueprint('tool', __name__)

@@ -21,7 +22,7 @@ tool = Blueprint('tool', __name__)
def get_tools():
view = request.args.get('view')
resource_type = 'tool'
tools_query = Resource.query.filter_by(type=resource_type)
tools_query = Resource.query.filter_by(type=resource_type).order_by(func.random())
for key in request.args.keys():
if key != 'view':
if (key == 'practice' and request.args.get(key) != ''):

Loading…
Отказ
Запис