def save(self, username): cd=self.cleaned_data content=cd['guestbook'] now = datetime.datetime.now() user=username guestbook=GuestBook( user=user, content=content, created=now ) guestbook.save()
def get(self, sporocilo_id): if users.is_current_user_admin(): sporocilo = GuestBook.get_by_id(int(sporocilo_id)) params = {"posamezno_sporocilo": sporocilo} return self.render_template("uredi_sporocilo.html", params=params) else: return self.render_template("nipravic.html")
def get(self): uporabnik = users.get_current_user() seznam_izbris = GuestBook.query(GuestBook.izbrisan == True).fetch() if uporabnik and uporabnik.nickname() == 'janko.pirih': logiran = True logout_url = users.create_logout_url( '/projects/guest-book/pregled-izbris') params = { 'uporabnik': uporabnik, 'logiran': logiran, 'logout_url': logout_url, 'seznam_izbris': seznam_izbris } else: logiran = False login_url = users.create_login_url( '/projects/guest-book/pregled-izbris') params = { 'uporabnik': uporabnik, 'logiran': logiran, 'login_url': login_url, 'seznam_izbiris': seznam_izbris } return self.render_template("seznam_izbris.html", params=params)
def post(self, guestbook_id): guestbook = GuestBook.get_by_id(int(guestbook_id)) guestbook.delete = True guestbook.put() time.sleep(0.1) return self.redirect_to('guestbook')
def get(self, sporocilo_id): uporabnik = users.get_current_user() if uporabnik: sporoilo = GuestBook.get_by_id(int(sporocilo_id)) params = {"sporocilo": sporoilo} return self.render_template("uredi_sporocilo.html", params=params) else: return self.redirect_to("guest-book")
def post(self, vnos_id): # to metodo naredimo zaradi shrani gumba sporocilce = GuestBook.get_by_id( int(vnos_id)) # potegnemo staro sporocilo iz baze sporocilce.poimenovanje = self.request.get("novo-poimenovanje") sporocilce.posta = self.request.get("nova-posta") sporocilce.besedilo = self.request.get("novo-besedilo") sporocilce.put() return self.redirect_to("seznam-sporocil")
def get(self): uporabnik = users.get_current_user() if uporabnik: seznam = GuestBook.query(GuestBook.izbrisan == False).fetch() params = {"seznam": seznam} return self.render_template("pregled.html", params=params) else: return self.redirect_to("guest-book")
def get(self, sporocilo_id): uporabnik = users.get_current_user() if uporabnik: # vrne objekt vsa polja ki jih vsebuje sporocilo s dolocenim ID -jem sporocilo = GuestBook.get_by_id(int(sporocilo_id)) params = {"sporocilo": sporocilo} return self.render_template("pregled_posamezno.html", params=params) else: return self.redirect_to("guest-book")
def get(self, sporocilo_id): uporabnik = users.get_current_user() if uporabnik.nickname() == "janko.pirih": sporocilo = GuestBook.get_by_id(int(sporocilo_id)) params = {"sporocilo": sporocilo} return self.render_template("obnovi.html", params=params) else: return self.redirect_to("seznam-izbirs")
def post(self): fullname = self.request.get('fullname') email = self.request.get('email') message = self.request.get('message') if not fullname: fullname = 'Anonymous' if '<script>' in message: return self.write("You can't inject your JavaScript here!") guestbook = GuestBook(fullname=fullname, email=email, message=message.replace('<script>', '')) guestbook.put() time.sleep(0.1) # quicker refresh rate return self.redirect_to('guestbook')
def post(self): ime = self.request.get("ime") email = self.request.get("email") sporocilo = self.request.get("sporocilo") msg = GuestBook(ime=ime, email=email, sporocilo=sporocilo) params = {'msg': msg} if msg.ime == "": msg.ime = "Neznanec" msg.put() return self.render_template("vnos.html", params=params) elif msg.sporocilo == "" or msg.sporocilo[0] == " ": msg.sporocilo = "privzeto besedilo - uporabnik ni vpisal teksta" msg.put() return self.render_template("vnos.html", params=params) else: msg.put() return self.render_template("vnos.html", params=params)
def post(self): ime = self.request.get("input_ime") email = self.request.get("input_email") besedilo = self.request.get("input_sporocilo") if not ime: ime = "Uporabnik zeli ostati neimenovan." uporabnik = GuestBook(imepriimek=ime, enaslov=email, sporocilo=besedilo) uporabnik.put() params = { "imegosta": ime, "emailgosta": email, "sporocilogosta": besedilo } return self.render_template("rezultat.html", params)
def post(self, guestbook_id): fullname = self.request.get('fullname') email = self.request.get('email') message = self.request.get('message') guestbook = GuestBook.get_by_id(int(guestbook_id)) guestbook.fullname = fullname guestbook.email = email guestbook.message = message guestbook.put() time.sleep(0.1) return self.redirect_to('guestbook')
def post(self): imeinupriimek = self.request.get("imepriimek") email3 = self.request.get("email") message2 = self.request.get("sporocilo") if not imeinupriimek: imeinupriimek = "neznanec" gost = GuestBook(poimenovanje=imeinupriimek, posta=email3, besedilo=message2) gost.put() podatki = { "namesurname": imeinupriimek, "email2": email3, "message": message2 } return self.render_template("rezultat.html", podatki)
def post(self): ime = self.request.get("ime") email = self.request.get("email") sporocilo = self.request.get("sporocilo") msg = GuestBook(ime=ime, email=email, sporocilo=sporocilo) params = {"msg": msg} if msg.ime == "": msg.ime = "Neznanec" msg.put() return self.render_template("vnos.html", params=params) elif msg.sporocilo == "" or msg.sporocilo[0] == " ": msg.sporocilo = "privzeto besedilo - uporabnik ni vpisal teksta" msg.put() return self.render_template("vnos.html", params=params) else: msg.put() return self.render_template("vnos.html", params=params)
def get(self): uporabnik = users.get_current_user() seznam_izbris = GuestBook.query(GuestBook.izbrisan == True).fetch() if uporabnik and uporabnik.nickname() == 'janko.pirih': logiran = True logout_url = users.create_logout_url('/projects/guest-book/pregled-izbris') params ={'uporabnik': uporabnik, 'logiran': logiran, 'logout_url': logout_url, 'seznam_izbris': seznam_izbris} else: logiran = False login_url = users.create_login_url('/projects/guest-book/pregled-izbris') params = {'uporabnik': uporabnik, 'logiran': logiran, 'login_url': login_url,'seznam_izbiris': seznam_izbris} return self.render_template("seznam_izbris.html", params=params)
def get(self): uporabnik = users.get_current_user() seznam_izbris = GuestBook.query(GuestBook.izbrisan == True).fetch() if uporabnik and uporabnik.nickname() == "janko.pirih": prijavljen = True logout_url = users.create_logout_url("/projects/guest-book/pregled-izbris") params = { "uporabnik": uporabnik, "prijavljen": prijavljen, "logout_url": logout_url, "seznam_izbris": seznam_izbris, } else: prijavljen = False login_url = users.create_login_url("/projects/guest-book/pregled-izbris") params = { "uporabnik": uporabnik, "logiran": prijavljen, "login_url": login_url, "seznam_izbiris": seznam_izbris, } return self.render_template("seznam_izbris.html", params=params)
def guestbook(): form = GuestBookForm() if form.validate_on_submit(): nickname = form.nickname.data text = form.text.data email = form.email.data guesttext = GuestBook(nickname, text, email) db.session.add(guesttext) db.session.commit() return redirect(url_for('guestbook')) # 查询数据 guestbook = GuestBook.query.all() # guestbook = GuestBook.query.filter_by(id=2).first() # guestbook = GuestBook.query.filter_by(nickname='aaa1') # 修改数据 # guestbook = GuestBook.query.filter_by(id=2).first() # guestbook.nickname='aaa2' # guestbook.email='*****@*****.**' # db.session.add(guestbook) # db.session.commit() # 批量修改数据 # guestbook = GuestBook.query.all() # for data in guestbook: # if data.id == 2: # data.nickname = data.nickname+'3' # db.session.add(data) # db.session.commit() # print guestbook return render_template('guestbook.html', title='留言簿', form=form, guestbook=guestbook)
def post(self, sporocilo_id): sporocilo = GuestBook.get_by_id(int(sporocilo_id)) sporocilo.izbrisano = True sporocilo.put() self.redirect_to("seznam_sporocil")
def post(self, sporocilo_id): sporocilo = GuestBook.get_by_id(int(sporocilo_id)) sporocilo.sporocilo = self.request.get("nov_tekst") sporocilo.put() self.redirect_to("seznam_sporocil")
def get(self, sporocilo_id): sporocilo = GuestBook.get_by_id(int(sporocilo_id)) params = {"posamezno_sporocilo": sporocilo} return self.render_template("uredi_sporocilo.html", params=params)
def get(self): seznam = GuestBook.query(GuestBook.izbrisan == False).fetch() params = {"seznam":seznam} return self.render_template("pregled.html", params=params)
def post(self, sporocilo_id): sporocilo = GuestBook.get_by_id(int(sporocilo_id)) sporocilo.izbrisan = False sporocilo.put() return self.redirect_to("seznam-sporocil")
def post(self, vnos_id): sporocilce = GuestBook.get_by_id( int(vnos_id)) # potegnemo staro sporocilo iz baze sporocilce.izbris = True sporocilce.put() return self.redirect_to("seznam-sporocil")
def get(self, vnos_id): # Iz baze vzamemo sporocilo, katerega id je enak podanemu sporocilce = GuestBook.get_by_id(int(vnos_id)) params = {"posamezno_sporocilce": sporocilce} return self.render_template("izbrisi_sporocilo.html", params=params)
def get(self): list = GuestBook.query(GuestBook.delete == False).fetch() params = {'list': list} return self.render_template('guestbook.html', params=params)
def get(self, sporocilo_id): sporocilo = GuestBook.get_by_id(int(sporocilo_id)) params = {"sporocilo": sporocilo} return self.render_template("izbris_sporocila.html", params=params)
def post(self, vnos_id): sporocilce = GuestBook.get_by_id(int(vnos_id)) sporocilce.key.delete() return self.redirect_to("kos-sporocil")
def get(self, sporocilo_id): sporocilo = GuestBook.get_by_id(int(sporocilo_id)) params = {'sporocilo': sporocilo} return self.render_template('obnovi.html',params=params)
def get(self, sporocilo_id): sporocilo = GuestBook.get_by_id(int(sporocilo_id)) params = {"sporocilo":sporocilo} return self.render_template("izbris_sporocila.html", params=params)
def post(self, sporocilo_id): vnos = self.request.get("sporocilo") sporocilo = GuestBook.get_by_id(int(sporocilo_id)) sporocilo.sporocilo = vnos sporocilo.put() return self.redirect_to("seznam-sporocil")
def get(self, sporocilo_id): sporocilo = GuestBook.get_by_id(int(sporocilo_id)) params = {'sporocilo': sporocilo} return self.render_template('obnovi.html', params=params)
def post(self, sporocilo_id): sporocilo = GuestBook.get_by_id(int(sporocilo_id)) sporocilo.key.delete() return self.redirect_to("seznam-izbirs")
def get(self): seznam = GuestBook.query(GuestBook.izbris == False).fetch() podatki = {"seznam": seznam} return self.render_template("seznam.html", podatki)
def post(self, sporocilo_id): sporocilo = GuestBook.get_by_id(int(sporocilo_id)) sporocilo.key.delete() return self.redirect_to('seznam-izbirs')
def get(self, sporocilo_id): # vrne objekt vsa polja ki jih vsebuje sporocilo s dolocenim ID -jem sporocilo = GuestBook.get_by_id(int(sporocilo_id)) params = {"sporocilo":sporocilo} return self.render_template("pregled_posamezno.html", params=params)
def post(self, sporocilo_id): sporocilo = GuestBook.get_by_id(int(sporocilo_id)) sporocilo.izbrisan = False sporocilo.put() return self.redirect_to('seznam-sporocil')
def get(self, guestbook_id): guestbook = GuestBook.get_by_id(int(guestbook_id)) params = {'guestbook': guestbook} return self.render_template('delete_guestbook.html', params=params)
def get(self): seznam = GuestBook.query(GuestBook.izbrisan == False).fetch() params = {"seznam": seznam} return self.render_template("pregled.html", params=params)
def get(self): kos_seznam = GuestBook.query(GuestBook.izbris == True).fetch() podatki = {"kos_seznam": kos_seznam} return self.render_template("kos_seznam.html", podatki)
def get(self, sporocilo_id): # vrne objekt vsa polja ki jih vsebuje sporocilo s dolocenim ID -jem sporocilo = GuestBook.get_by_id(int(sporocilo_id)) params = {"sporocilo": sporocilo} return self.render_template("pregled_posamezno.html", params=params)
def get(self): seznam = GuestBook.query().fetch() params = {"seznam": seznam} return self.render_template("guestbook.html", params=params)