Beispiel #1
0
def registerUser():
    form = UserRegisterForm(request.form)
    if form.validate_on_submit():
        user = User(
                name = form.name.data,
                surname = form.surname.data,
                email = form.email.data,
                password = utils.encrypt_password(form.password.data),
                birth_date = form.birth_date.data,
                #country = form.country.data,
                il_id = form.il.data if form.il.data > 0 else None,
                ilce_id = form.ilce.data if form.ilce.data > 0 else None,
                semt_id = form.semt.data if form.semt.data > 0 else None,
                confirmed = False,
                active = True
        )
        for i in form.interests.data:
			#dao.addObject(interests_users(interest_id=i, user_id=user.id))
			user.interests.append(dao.getObject(i, InterestArea))
        dao.addObject(user)
        dao.commit()
        login_user(user)
        flash(u'Kayıt oldunuz', 'info')
        return redirect(url_for('index'))
    return render_template('register_user.html', form=form)
Beispiel #2
0
def addBook():
    if 'editor' not in current_user.roles and 'admin' not in current_user.roles:
        flash(u'Bu sayfaya erişim izniniz yok.', 'warning')
        return redirect(url_for('index'))
    form = BookAddForm(request.form)
    if form.validate_on_submit():
        author = dao.getObject(form.author.data, Author)
        
        publisher = None
        ebook_fname = None
        image_fname = None
        if form.publisher.data:
            publisher = dao.getObject(form.publisher.data, Publisher)
        if form.ebook.data:
            ebook_fname = ebooks.save(request.files[form.ebook.name])
        if form.image.data:
            image_fname = book_images.save(request.files[form.image.name])
        book = Book(
                name = form.name.data,
                author = author,
                publication_place= form.publication_place.data,
                publication_year= form.publication_year.data,
                publisher = publisher,
                isbn = form.isbn.data,
                page_amount = form.page_amount.data,
                description = form.description.data,
                ebook_fname = ebook_fname,
                image_fname = image_fname
        )
        dao.addObject(book)
        dao.commit();
        flash('Kitap eklendi.', 'info')
        return redirect(url_for('index'))
    return render_template('add_book.html', form=form)
Beispiel #3
0
def writeComment(book_id):
    book = dao.getObject(book_id, Book)
    if book is None:
        flash(u'Böyle bir kitap yok!', 'warning')
        return redirect(request.referrer or url_for('index'))
        
    form = WriteCommentForm(request.form)
    if form.validate_on_submit():
        comment = Comment(
            text = form.comment.data,
            user = current_user,
            book = book,
            time_created = datetime.now(),
            time_last_modified = None
        )
        dao.addObject(comment)
        dao.commit()
        flash(u'Yorum yazıldı!', 'info')
    return redirect(request.referrer or url_for('bookPage', book_id=book.id))
Beispiel #4
0
def writeSummary(assoc_id):
    assoc = dao.getObject(assoc_id, UserBook)
    if assoc is None or assoc not in current_user.book_assocs or assoc.status != Status.have_read or assoc.summary != None:
        flash(u'Sadece okumuş olduğunuz kitaplar hakkında birer adet özet yazabilirsiniz!', 'warning')
        return redirect(request.referrer or url_for('index'))
    
    form = WriteSummaryForm(request.form)
    if form.validate_on_submit():
        summary = Summary(
            text = form.summary.data,
            time_created = datetime.now(),
            time_last_modified = None,
            userbook = assoc
        )
        dao.addObject(summary)
        dao.commit()
        flash(u'Özet yazıldı!', 'info')
        return redirect(url_for('bookPage', book_id=assoc.book.id))
    return render_template('write_summary.html', form=form)
Beispiel #5
0
def writeNote(assoc_id):
    assoc = dao.getObject(assoc_id, UserBook)
    if assoc is None or assoc.status != Status.reading:
        flash(u"Okumakta olmadığınız bir kitaba not alamazsınız", 'warning')
        return redirect(request.referrer or url_for('index'))
    note_form = WriteNoteForm(request.form)
    if note_form.validate_on_submit():
        note = Note(
            text = note_form.note.data,
            page = note_form.page.data,
            is_public = note_form.is_public.data,
            userbook = assoc,
            time_created = datetime.now(),
            time_last_modified = None
        )
        dao.addObject(note)
        dao.commit()
        flash(u'Not yazıldı!', 'info')
        return redirect(url_for('bookRead', book_id=assoc.book.id))
    else:
        flash(u'Not yazımı hatalı!', 'info')
        return redirect(url_for('bookRead', book_id=assoc.book.id, hide=""))