def get(self, id): nickname = "*****@*****.**" wk = Workspace.get_by_id(int(id)) if not wk: self.response.out.write("No such workspace") return user = users.get_current_user() if user: nickname = user.nickname() if wk.user.google_id != user.user_id() and not wk.demo: self.response.out.write("Not your workspace, %s" % nickname) return if not user and not wk.demo: self.redirect(users.create_login_url(self.request.uri)) else: path = 'templates/workspace.html' template = Template(file=path) template.user = nickname template.logout_url = users.create_logout_url("/") template.wk = Workspace.get_by_id(int(id)) template.id = id template.indent_strings = workspace.indent_strings template.indent_styles = workspace.indent_styles template.font_sizes = workspace.font_sizes template.font_faces = workspace.font_faces template.encodings = workspace.encodings template.sample_stylesheets = css.sample_stylesheets self.response.out.write(template)
def deleteworkspace(): data = request.args.get('jsdata') workspace = Workspace.get_by_id(data) workspace.delete() return render_template('deleted.html')
def hello(): users = [] workspaces= Workspace.query.all() user = get_jwt_identity() userid = User.get_by_username(user).id users.append(userid) reservations = Reservation.query.filter_by(reservor=userid).all() reser = [] for reservation in reservations: try: ids = reservation.workspace a = Workspace.get_by_id(ids) reservation.name = a.name reser.append(reservation) except: print("rip") resp = make_response(render_template('reservations.html', reservations=reservations, workspaces=workspaces, users=users )) return resp
def get(self, id, format): wk = Workspace.get_by_id(int(id)) if not wk: self.response.out.write("No such workspace") return # Check access if self.request.get("key") and wk.sharing_key == self.request.get("key"): pass elif wk.demo: pass else: user = users.get_current_user() if not user or wk.user.google_id != user.user_id(): self.response.out.write("Not logged in as the right user") return x = xhtml.parse(wk.content_xml(), wk, format) w = writer.Writer(wk) xhtml.recurse(x.documentElement, w, format, wk) html = w.to_html() # Re-encode the whole thing, in case out-of-range characters were in # elements names or attributes. html = encoding.encode_html(html, wk.encoding) if format == "text": self.response.headers["Content-Type"] = "text/plain; charset=%s" % wk.encoding self.response.out.write(html) else: path = 'templates/%s.html' % format template = Template(file=path) template.wk = wk if format == "code": html = cgi.escape(html) if format != "text": html = xhtml.expand_annotations(html) template.html = html template.id = id self.response.headers["Content-Type"] = "text/html; charset=%s" % wk.encoding if wk.encoding == "utf-8": self.response.out.write(unicode(template)) else: self.response.out.write(unicode(template).encode(wk.encoding))
def admin(): username = get_jwt_identity() user = User.get_by_username(username) if user.is_admin: workspaces = Workspace.query.all() reservations = Reservation.query.all() reser = [] i = 0 for reservation in reservations: try: ids = reservation.workspace ids2 = reservation.reservor a = Workspace.get_by_id(ids) b = User.get_by_id(ids2) reservation.correct_user = b.name reservation.name = a.name reser.append(reservation) except: print("rip") clients = User.query.all() return render_template('admin.html', reservations=reservations, workspaces=workspaces, clients=clients) else: return render_template('notadmin.html')