def sheets_tag(request, tag, public=True, group=None): """ View sheets for a particular tag. """ if public: if request.flavour == "mobile": return s2_sheets_by_tag(request, tag) elif not request.COOKIES.get('s1'): return s2_sheets_by_tag(request, tag) sheets = get_sheets_by_tag(tag) elif group: sheets = get_sheets_by_tag(tag, group=group) else: sheets = get_sheets_by_tag(tag, uid=request.user.id) in_group = request.user.is_authenticated() and group in [g.name for g in get_user_groups(request.user.id)] groupCover = Group().load({"name": group}).coverUrl if Group().load({"name": group}) else None return render_to_response('tag.html', { "tag": tag, "sheets": sheets, "public": public, "group": group, "groupCover": groupCover, "in_group": in_group, }, RequestContext(request)) return render_to_response('sheet_tags.html', {"tags_list": tags_list, }, RequestContext(request))
def sheets_tag(request, tag, public=True, group=None): """ View sheets for a particular tag. """ if public: if request.flavour == "mobile": return s2_sheets_by_tag(request, tag) elif not request.COOKIES.get('s1'): return s2_sheets_by_tag(request, tag) sheets = get_sheets_by_tag(tag) elif group: sheets = get_sheets_by_tag(tag, group=group) else: sheets = get_sheets_by_tag(tag, uid=request.user.id) in_group = request.user.is_authenticated() and group in [g.name for g in request.user.groups.all()] groupCover = Group().load({"name": group}).coverUrl if Group().load({"name": group}) else None return render_to_response('tag.html', { "tag": tag, "sheets": sheets, "public": public, "group": group, "groupCover": groupCover, "in_group": in_group, }, RequestContext(request)) return render_to_response('sheet_tags.html', {"tags_list": tags_list, }, RequestContext(request))
def sheets_list(request, type=None): """ List of all public/your/all sheets either as a full page or as an HTML fragment """ if not type: # Sheet Splash page return s2_sheets(request) response = {"status": 0} if type == "public": return s2_sheets_by_tag(request, "All Sheets") elif type == "private" and request.user.is_authenticated(): return s2_sheets_by_tag(request, "My Sheets") elif type == "private" and not request.user.is_authenticated(): return redirect("/login?next=/sheets/private")
def sheets_list(request, type=None): """ List of all public/your/all sheets either as a full page or as an HTML fragment """ if not type: # Sheet Splash page if request.flavour == "mobile": return s2_sheets(request) elif not request.COOKIES.get('s1'): return s2_sheets(request) query = {"status": "public"} public = db.sheets.find(query).sort([["dateModified", -1]]).limit(32) public_tags = recent_public_tags() if request.user.is_authenticated(): query = {"owner": request.user.id} your = db.sheets.find(query).sort([["dateModified", -1]]).limit(3) your_tags = sheet_tag_counts(query) your_tags = order_tags_for_user(your_tags, request.user.id) collapse = your.count() > 3 else: your = your_tags = collapse = None return render_to_response('sheets_splash.html', { "public_sheets": public, "public_tags": public_tags, "your_sheets": your, "your_tags": your_tags, "collapse_private": collapse, "groups": get_user_groups(request.user.id) }, RequestContext(request)) response = { "status": 0 } if type == "public": if request.flavour == "mobile": return s2_sheets_by_tag(request,"All Sheets") elif not request.COOKIES.get('s1'): return s2_sheets_by_tag(request,"All Sheets") query = {"status": "public"} response["title"] = "Public Source Sheets" response["public"] = True tags = recent_public_tags() elif type == "private" and request.user.is_authenticated(): if request.flavour == "mobile": return s2_sheets_by_tag(request,"My Sheets") elif not request.COOKIES.get('s1'): return s2_sheets_by_tag(request,"My Sheets") query = {"owner": request.user.id or -1 } response["title"] = "Your Source Sheets" response["groups"] = get_user_groups(request.user.id) tags = sheet_tag_counts(query) tags = order_tags_for_user(tags, request.user.id) elif type == "private" and not request.user.is_authenticated(): return redirect("/login?next=/sheets/private") sheets = db.sheets.find(query).sort([["dateModified", -1]]) if "fragment" in request.GET: return render_to_response('elements/sheet_table.html', {"sheets": sheets}) response["sheets"] = sheets response["tags"] = tags return render_to_response('sheets_list.html', response, RequestContext(request))
def sheets_tag(request, tag, public=True, group=None): return s2_sheets_by_tag(request, tag)
def sheets_list(request, type=None): """ List of all public/your/all sheets either as a full page or as an HTML fragment """ if not type: # Sheet Splash page if request.flavour == "mobile": return s2_sheets(request) elif not request.COOKIES.get('s1'): return s2_sheets(request) query = {"status": "public"} public = db.sheets.find(query).sort([["dateModified", -1]]).limit(32) public_tags = recent_public_tags() if request.user.is_authenticated(): query = {"owner": request.user.id} your = db.sheets.find(query).sort([["dateModified", -1]]).limit(3) your_tags = sheet_tag_counts(query) your_tags = order_tags_for_user(your_tags, request.user.id) collapse = your.count() > 3 else: your = your_tags = collapse = None return render_to_response('sheets_splash.html', { "public_sheets": public, "public_tags": public_tags, "your_sheets": your, "your_tags": your_tags, "collapse_private": collapse, "groups": get_user_groups(request.user) }, RequestContext(request)) response = { "status": 0 } if type == "public": if request.flavour == "mobile": return s2_sheets_by_tag(request,"All Sheets") elif not request.COOKIES.get('s1'): return s2_sheets_by_tag(request,"All Sheets") query = {"status": "public"} response["title"] = "Public Source Sheets" response["public"] = True tags = recent_public_tags() elif type == "private": if request.flavour == "mobile": return s2_sheets_by_tag(request,"My Sheets") elif not request.COOKIES.get('s1'): return s2_sheets_by_tag(request,"My Sheets") query = {"owner": request.user.id or -1 } response["title"] = "Your Source Sheets" response["groups"] = get_user_groups(request.user) tags = sheet_tag_counts(query) tags = order_tags_for_user(tags, request.user.id) elif type == "allz": query = {} response["title"] = "All Source Sheets" response["public"] = True tags = [] sheets = db.sheets.find(query).sort([["dateModified", -1]]) if "fragment" in request.GET: return render_to_response('elements/sheet_table.html', {"sheets": sheets}) response["sheets"] = sheets response["tags"] = tags return render_to_response('sheets_list.html', response, RequestContext(request))