Пример #1
0
 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()
Пример #2
0
 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")
Пример #3
0
    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)
Пример #4
0
    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')
Пример #5
0
 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")
Пример #6
0
 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")
Пример #7
0
 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")
Пример #8
0
 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")
Пример #9
0
    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")
Пример #10
0
    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')
Пример #11
0
    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)
Пример #12
0
    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)
Пример #13
0
    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')
Пример #14
0
    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)
Пример #15
0
    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)
Пример #16
0
    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)
Пример #17
0
    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)
Пример #18
0
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)
Пример #19
0
 def post(self, sporocilo_id):
     sporocilo = GuestBook.get_by_id(int(sporocilo_id))
     sporocilo.izbrisano = True
     sporocilo.put()
     self.redirect_to("seznam_sporocil")
Пример #20
0
 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")
Пример #21
0
 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)
Пример #22
0
 def get(self):
     seznam = GuestBook.query(GuestBook.izbrisan == False).fetch()
     params = {"seznam":seznam}
     return self.render_template("pregled.html", params=params)
Пример #23
0
 def post(self, sporocilo_id):
     sporocilo = GuestBook.get_by_id(int(sporocilo_id))
     sporocilo.izbrisan = False
     sporocilo.put()
     return self.redirect_to("seznam-sporocil")
Пример #24
0
 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")
Пример #25
0
 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)
Пример #26
0
    def get(self):
        list = GuestBook.query(GuestBook.delete == False).fetch()
        params = {'list': list}

        return self.render_template('guestbook.html', params=params)
Пример #27
0
 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)
Пример #28
0
 def post(self, vnos_id):
     sporocilce = GuestBook.get_by_id(int(vnos_id))
     sporocilce.key.delete()
     return self.redirect_to("kos-sporocil")
Пример #29
0
 def get(self, sporocilo_id):
     sporocilo = GuestBook.get_by_id(int(sporocilo_id))
     params = {'sporocilo': sporocilo}
     return self.render_template('obnovi.html',params=params)
Пример #30
0
 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)
Пример #31
0
 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")
Пример #32
0
 def get(self, sporocilo_id):
     sporocilo = GuestBook.get_by_id(int(sporocilo_id))
     params = {'sporocilo': sporocilo}
     return self.render_template('obnovi.html', params=params)
Пример #33
0
    def post(self, sporocilo_id):
        sporocilo = GuestBook.get_by_id(int(sporocilo_id))

        sporocilo.key.delete()
        return self.redirect_to("seznam-izbirs")
Пример #34
0
 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")
Пример #35
0
 def get(self):
     seznam = GuestBook.query(GuestBook.izbris == False).fetch()
     podatki = {"seznam": seznam}
     return self.render_template("seznam.html", podatki)
Пример #36
0
    def post(self, sporocilo_id):
        sporocilo = GuestBook.get_by_id(int(sporocilo_id))

        sporocilo.key.delete()
        return self.redirect_to('seznam-izbirs')
Пример #37
0
 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)
Пример #38
0
 def post(self, sporocilo_id):
     sporocilo = GuestBook.get_by_id(int(sporocilo_id))
     sporocilo.izbrisan = False
     sporocilo.put()
     return self.redirect_to('seznam-sporocil')
Пример #39
0
 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)
Пример #40
0
 def get(self):
     seznam = GuestBook.query(GuestBook.izbrisan == False).fetch()
     params = {"seznam": seznam}
     return self.render_template("pregled.html", params=params)
Пример #41
0
 def get(self):
     kos_seznam = GuestBook.query(GuestBook.izbris == True).fetch()
     podatki = {"kos_seznam": kos_seznam}
     return self.render_template("kos_seznam.html", podatki)
Пример #42
0
 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)
Пример #43
0
 def get(self):
     seznam = GuestBook.query().fetch()
     params = {"seznam": seznam}
     return self.render_template("guestbook.html", params=params)