def user_detail(username): user = get_object_or_404(User, username=username) messages = user.message_set.order_by(('pub_date', 'desc')) return object_list('user_detail.html', messages, 'message_list', person=user)
def private_timeline(): user = auth.get_logged_in_user() messages = Message.select().where( Message.user << user.following()).order_by(Message.pub_date.desc()) return object_list('private_messages.html', messages, 'message_list')
def update_db(): url = 'http://www.unisport.dk/api/sample/' request = urlopen(url) response = request.read() j = json.loads(response) #Parsing all data from response data_list = j['latest'] #Getting list of dicts #Updating our database query = Products.delete() query.execute() for item in data_list: product = Products() product.kids = item['kids'] product.name = item['name'] product.sizes = item['sizes'] product.k_adalt = item['kid_adult'] product.free_porto = item['free_porto'] product.price = item['price'].replace(',', '.') product.package = item['package'] product.delivery = item['delivery'] product.url = item['url'] product.price_old = item['price_old'].replace(',', '.') product.img_url = item['img_url'] product.product_id = item['id'] product.women = item['women'] product.save() #After our database was successfully updated we #return results paginated by 10 products per page return object_list('products.html', Products.select(), paginate_by=10)
def user_detail(username): user = get_object_or_404(User, User.username == username) messages = user.message_set.order_by(Message.pub_date.desc()) return object_list('user_detail.html', messages, 'message_list', person=user)
def image_timeline(): """ function that is called when the url for images is being requested """ images = Image.select().order_by(('id', 'asc')) return object_list('images.html', images, 'image_list')
def private_timeline(): user = auth.get_logged_in_user() messages = Message.select().where( user__in=user.following() ).order_by(('pub_date', 'desc')) return object_list('private_messages.html', messages, 'message_list')
def dashboard(msg=None): user = auth.get_logged_in_user() try: books = Books.select().where( Books.ownership == user).order_by(Books.id.desc()) return object_list("book_list.html", books, 'book_list') except Books.DoesNotExist: return render_template("dashboard.html", msg=msg) return render_template("dashboard.html", msg=msg)
def bookmark(): user = auth.get_logged_in_user() # object_list automatically invoke PaginateQuery # capture request.args.get('page') to calucalte pagination bookmarks = user.Bookmarks return object_list('bookmark_list.html', bookmarks, 'bookmarks', paginate_by=PERPAGE, user=user)
def tugas_list(): tugass = ( Tugas.select(Tugas, fn.Count(KumpulTugas.id).alias('k_tugas_count')) .join(KumpulTugas, JOIN.LEFT_OUTER, on=(KumpulTugas.tugas == Tugas.id)) .join(MataKuliah, on=(Tugas.mata_kuliah == MataKuliah.id)) .group_by(Tugas) .where(MataKuliah.dosen == current_user())) return object_list('dosen/tugas/list.html', tugass, var_name='tugass', paginate_by=10)
def private_timeline(): user = auth.get_logged_in_user() messages = Message.select().where(Message.user << user.following()).order_by(Message.pub_date.desc()) return object_list('profile.html', messages, 'message_list', course_1_name='jhdsjhdjs', progress='50', course_1_description='opis opis opis', )
def model(vendor, model): """ View informations for a model for one vendor """ m = Models() model_infos = m.get_model(model) comment = comments.select().where(comments.model == model) return object_list('model.html', comment, 'comment_list', vendor=vendor, model=model, model_infos=model_infos)
def index(): user = auth.get_logged_in_user() if user: return redirect(url_for('bookmark')) else: # random pick 30 bookmarks, If Database is MySQL, please use fn.Rand() # fn come from, from peewee import * bookmarks = Bookmark.select().order_by(fn.Random()).limit(PERPAGE) return object_list('bookmark_list.html', bookmarks, 'bookmarks', paginate_by=PERPAGE)
def private_timeline(): user = auth.get_logged_in_user() messages = Message.select().where( Message.user << user.following()).order_by(Message.pub_date.desc()) return object_list( 'profile.html', messages, 'message_list', course_1_name='jhdsjhdjs', progress='50', course_1_description='opis opis opis', )
def private_timeline(): user = auth.get_logged_in_user() messages = Message.select().where(Message.user << user.following()).order_by(Message.pub_date.desc()) return object_list('profile.html', messages, 'message_list', ps_nr_points=' 57', ps_nr_badges=' 5', html_nr_points=' 77', html_nr_badges=' 3', py_nr_points=' 77', py_nr_badges=' 3', usersname=user, )
def matkul_list(): matkuls = MataKuliah.select().order_by(MataKuliah.kode.desc()) return object_list('admin/matkul/list.html', matkuls, var_name='matkuls', paginate_by=10)
def user_list(): users = User.select().order_by(User.username) return object_list("user_list.html", users, "user_list")
def city_list(): obj_list = City.select().order_by('name') return object_list('city_list.html', obj_list, "obj_list")
def public_timeline(): news_list = OursNews.select().order_by('score') return object_list('index.html', news_list, "news_list")
def public_timeline(): messages = Message.select().order_by(Message.pub_date.desc()) return object_list("timeline.html", messages, "message_list")
def public_timeline(): messages = Message.select().order_by(('pub_date', 'desc')) return object_list('public_messages.html', messages, 'message_list')
def user_list(): users = User.select() _level = request.args.get('level', None) if _level: users = users.join(Level).where(Level.name == _level) return object_list('admin/user/list.html', users, 'users', paginate_by=10)
def city_detail(city_id): city = get_object_or_404(City, id=city_id) obj_list = Pinche.select().where(city=city).order_by('pub_date') return object_list('city_detail.html', obj_list, "obj_list")
def public_timeline(): messages = Message.select().order_by(Message.pub_date.desc()) return object_list('public_messages.html', messages, 'message_list')
def user_list(): users = User.select().order_by(User.username) return object_list('user_list.html', users, 'user_list')
def homepage(): stories = Story.select() return object_list('homepage.html', stories, 'stories')
def followers(): user = auth.get_logged_in_user() return object_list('user_followers.html', user.followers(), 'user_list')
def index(): return object_list('index.html', Bookmark.select())
def post_list(): posts = Post.select().order_by(Post.date_created.desc()) return object_list('admin/post/list.html', posts, var_name='posts', paginate_by=10)
def goods_list(): goods = Goods.select() return object_list('goods_list.html', goods, 'goods_list')
def pinche_list(): obj_list = Pinche.select().order_by('pub_date') return object_list('pinche_list.html', obj_list, "obj_list")
def following(): user = auth.get_logged_in_user() return object_list('user_following.html', user.following(), 'user_list')
def user_detail(username): user = get_object_or_404(User, User.username==username) messages = user.message_set.order_by(Message.pub_date.desc()) return object_list('user_detail.html', messages, 'message_list', person=user)
def public_timeline(): messages = Message.select().order_by(Message.pub_date.desc()) return object_list('forum.html', messages, 'message_list')
def home(): posts = Post.select().where(Post.publik == True) return object_list('home.html', posts, var_name='posts')
def public_timeline(): userf = auth.get_logged_in_user() messages = Message.select().order_by(Message.pub_date.desc()) return object_list('forum.html', messages, 'message_list', forumusername=userf, forumname='The Forum Wall',)