Pārlūkot izejas kodu

randomly order resources when on regular view

joel
Simon Bowie pirms 1 gada
vecāks
revīzija
55671f78ac
3 mainītis faili ar 6 papildinājumiem un 3 dzēšanām
  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 Parādīt failu

@@ -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 Parādīt failu

@@ -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 Parādīt failu

@@ -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) != ''):

Notiek ielāde…
Atcelt
Saglabāt