def preview(communityname): comlist = Lists.showlist(communityname) preview = [film["image"] for film in comlist][:4] # Add stock photo's if list is too short. while len(preview) < 4: preview.append("https://cdn2.iconfinder.com/data/icons/cinema-and-television/500/Entertainment_film_film_reel_film_roll_movie_reel_roll_theate-512.png") return preview
def mylist(): # Remove item from list. if request.method == "POST": Lists.remove_item(Lists.get_listid(session["username"]), request.form.get("listremove")) # Get all information. information = Lists.showlist(session["username"]) # Show list. return render_template("lists.html", information=information)
def myprofile(): # Show personal profile. return render_template("profilepage.html", movies=Lists.showlist(session["username"]), communities=com.mycommunities())
def community(): # Gather required information. films = Lists.showlist(request.args.get('community')) comments = com.community_comments(request.args.get('community')) if request.method == "POST": # Get changed community description and save it. if request.form.get("save"): com.change_description(request.form.get("save"), request.args.get('community')) return render_template( "community.html", mycom=com.mycommunities(), comments=comments, page=com.show(request.args.get('community'))[0], members=com.showmembers(request.args.get('community')), films=films, member=com.member(session["user_id"], request.args.get('community'))) # Lets user join community. if request.form.get("comaction") == "join": com.join(session["username"], request.args.get('community')) return render_template( "community.html", mycom=com.mycommunities(), comments=comments, page=com.show(request.args.get('community'))[0], members=com.showmembers(request.args.get('community')), films=films, member=com.member(session["user_id"], request.args.get('community'))) # Lets user leave community. elif request.form.get("comaction") == "leave": com.remove_member(session["username"], request.args.get('community')) return render_template( "community.html", mycom=com.mycommunities(), comments=comments, page=com.show(request.args.get('community'))[0], members=com.showmembers(request.args.get('community')), films=films, member=com.member(session["user_id"], request.args.get('community'))) # Removes item from community list. elif request.form.get("comlistremove"): Lists.remove_item(Lists.get_listid(request.args.get('community')), request.form.get("comlistremove")) films = Lists.showlist(request.args.get('community')) return render_template( "community.html", mycom=com.mycommunities(), comments=comments, page=com.show(request.args.get('community'))[0], members=com.showmembers(request.args.get('community')), films=films, member=com.member(session["user_id"], request.args.get('community'))) # Save comment. if request.form.get("commented"): username = session["username"] com.save_comment(username, request.args.get('community'), request.form.get("comment")) comments = com.community_comments(request.args.get('community')) return render_template( "community.html", mycom=com.mycommunities(), comments=comments, page=com.show(request.args.get('community'))[0], members=com.showmembers(request.args.get('community')), films=films, member=com.member(session["user_id"], request.args.get('community'))) # Add item to user list. if request.form.get("listadd"): Lists.add_item(User.get_list_id(session["username"]), request.form.get("listadd")) return render_template( "community.html", mycom=com.mycommunities(), comments=comments, page=com.show(request.args.get('community'))[0], members=com.showmembers(request.args.get('community')), films=films, member=com.member(session["user_id"], request.args.get('community'))) # Add item to other community list. elif request.form.get("comadd"): print(request.form.get("comadd") + "fwkogfwkefgjew") Lists.add_item(com.get_list_id(request.args.get("community")), request.form.get("comadd")) return render_template( "community.html", mycom=com.mycommunities(), comments=comments, page=com.show(request.args.get('community'))[0], members=com.showmembers(request.args.get('community')), films=films, member=com.member(session["user_id"], request.args.get('community'))) #wrong post request else: return render_template( "community.html", mycom=com.mycommunities(), comments=comments, page=com.show(request.args.get('community'))[0], members=com.showmembers(request.args.get('community')), films=films, member=com.member(session["user_id"], request.args.get('community'))) # Render page. else: return render_template( "community.html", mycom=com.mycommunities(), comments=comments, page=com.show(request.args.get('community'))[0], members=com.showmembers(request.args.get('community')), films=films, member=com.member(session["user_id"], request.args.get('community')))