Exemple #1
0
    def new(self):
        fs = EventForm('event-new')

        if request.POST and fs.fields.cancel.id in request.POST:
            return redirect_to(current_user().url())

        if request.POST and fs.is_valid(request.POST):
            node = model.Event()
            node.title = fs.fields.title.value
            node.summary = fs.fields.summary.value
            node.start = fs.fields.start.value
            node.finish = fs.fields.finish.value
            node.node_user_id = current_user().id

            meta.Session.add(node)
            meta.Session.commit()
            flash(u'Событие успешно добавлено')
            return redirect_to(node.url())

        c.form = fs
        c.fs = fs.fields

        if is_ajax():
            result = render('/event/new_partial.html')
        else:
            result = render('/event/new.html')
        if request.POST:
            result = fs.htmlfill(result)
        return result
Exemple #2
0
    def new(self, event_id):
        event_node = self._get_row(model.Event, event_id)
        self._check_access(event_node)

        fs = AlbumForm('album-new')

        if request.POST and fs.fields.cancel.id in request.POST:
            return redirect_to(event_node.url())

        if request.POST and fs.is_valid(request.POST):
            node = model.Album()
            node.settings = picasa.photos(
                fs.fields.user.value, fs.fields.albumid.value, limit=30
            )
            node.node_user_id = current_user().id

            meta.Session.add(node)
            event_node.albums.append(node)
            meta.Session.commit()
            flash(u'Альбом успешно добавлен')
            if self.back_page():
                return redirect_to(**self.back_page())
            return redirect_to(event_node.url())

        c.form = fs
        c.fs = fs.fields

        if is_ajax():
            result = render('/album/new_partial.html')
        else:
            result = render('/album/new.html')
        if request.POST:
            result = fs.htmlfill(result)
        return result
Exemple #3
0
    def reload(self, id):
        node = self._get_row(model.Album, id)
        event_node = node.event
        self._check_access(event_node)

        album = gdata.GDataFeedFromString(node.settings)
        node.settings = urlopen(album.GetSelfLink().href).read()

        meta.Session.commit()
        flash(u'Альбом успешно обновлен')
        if self.back_page():
                return redirect_to(**self.back_page())
        return redirect_to(event_node.url())
Exemple #4
0
    def publish(self, id, published):
        node = self._get_row(model.Article, id)

        if published=='1':
            node.published = datetime.now()
            message = u'Статья успешно опубликована'
        else:
            node.published = None
            message = u'Статья успешно сохранена как черновик'

        meta.Session.commit()
        flash(message)
        if self.back_page():
            return redirect_to(**self.back_page())
        return redirect_to(node.url())
Exemple #5
0
    def publish(self, id, published):
        node = self._get_row(model.Article, id)

        if published == "1":
            node.published = datetime.now()
            message = u"Статья успешно опубликована"
        else:
            node.published = None
            message = u"Статья успешно сохранена как черновик"

        meta.Session.commit()
        flash(message)
        if self.back_page():
            return redirect_to(**self.back_page())
        return redirect_to(node.url())
Exemple #6
0
    def edit(self, id):
        node = self._get_row(model.Article, id)

        fs = ArticleForm('article-edit', node.path)

        if request.POST and fs.fields.cancel.id in request.POST:
            if self.back_page():
                return redirect_to(**self.back_page())
            return redirect_to(node.url())

        if request.POST and fs.is_valid(request.POST):

            node.title = fs.fields.title.value
            node.content = fs.fields.content.value

            is_valid = True
            if not fs.fields.path.value:
                fs.fields.path.value = translit.slugify(node.title)
                is_valid = fs.is_valid(fs.get_values(use_ids=True))

            if is_valid:
                node.path = fs.fields.path.value

                meta.Session.commit()
                flash(u'Статья успешно сохранена')
                if fs.fields.save_view.id in request.POST:
                    return redirect_to(node.url())
                elif fs.fields.save_view_list.id in request.POST:
                    if node.label is not None:
                        return redirect_to(node.label)
                    return redirect_to('articles')

        if not request.POST:
            fs.set_values({
                'title': node.title,
                'path': node.path,
                'content': node.content
            })

        c.form = fs
        c.fs = fs.fields
        c.node = node

        if is_ajax():
            result = render('/article/edit_partial.html')
        else:
            result = render('/article/edit.html')
        return fs.htmlfill(result)
Exemple #7
0
    def remove(self, id):
        node = self._get_row(model.Event, id)
        if 1 == node.id:
            abort(403)
        self._check_access(node)

        fs = form.DeleteAcceptForm('event-remove')

        if request.POST:
            if fs.fields.save.id in request.POST:
                meta.Session.delete(node)
                meta.Session.commit()
                flash(u'Событие успешно удалено')
                c.is_full_redirect = True
                return self._redirect_to(controller='event',
                                         action='list',
                                         user=current_user().nickname)
            return redirect_to(node.url())
        else:
            c.form = fs
            if is_ajax():
                result = render('/util/delete_accept_partial.html')
            else:
                result = render('/util/delete_accept.html')
            return result
Exemple #8
0
    def edit(self, id):
        node = self._get_row(model.Article, id)

        fs = ArticleForm("article-edit", node.path)

        if request.POST and fs.fields.cancel.id in request.POST:
            if self.back_page():
                return redirect_to(**self.back_page())
            return redirect_to(node.url())

        if request.POST and fs.is_valid(request.POST):

            node.title = fs.fields.title.value
            node.content = fs.fields.content.value

            is_valid = True
            if not fs.fields.path.value:
                fs.fields.path.value = translit.slugify(node.title)
                is_valid = fs.is_valid(fs.get_values(use_ids=True))

            if is_valid:
                node.path = fs.fields.path.value

                meta.Session.commit()
                flash(u"Статья успешно сохранена")
                if fs.fields.save_view.id in request.POST:
                    return redirect_to(node.url())
                elif fs.fields.save_view_list.id in request.POST:
                    if node.label is not None:
                        return redirect_to(node.label)
                    return redirect_to("articles")

        if not request.POST:
            fs.set_values({"title": node.title, "path": node.path, "content": node.content})

        c.form = fs
        c.fs = fs.fields
        c.node = node

        if is_ajax():
            result = render("/article/edit_partial.html")
        else:
            result = render("/article/edit.html")
        return fs.htmlfill(result)
Exemple #9
0
    def remove(self, id):
        node = self._get_row(model.Article, id)

        fs = form.DeleteAcceptForm("article-remove")

        if request.POST:
            if fs.fields.save.id in request.POST:
                meta.Session.delete(node)
                meta.Session.commit()
                flash(u"Статья успешно удалена")
            if self.back_page() is not None:
                return redirect_to(**self.back_page())
            return redirect_to("articles")
        else:
            c.form = fs
            if is_ajax():
                result = render("/util/delete_accept_partial.html")
            else:
                result = render("/util/delete_accept.html")
            return result
Exemple #10
0
    def remove(self, id):
        node = self._get_row(model.Article, id)

        fs = form.DeleteAcceptForm('article-remove')

        if request.POST:
            if fs.fields.save.id in request.POST:
                meta.Session.delete(node)
                meta.Session.commit()
                flash(u'Статья успешно удалена')
            if self.back_page() is not None:
                return redirect_to(**self.back_page())
            return redirect_to('articles')
        else:
            c.form = fs
            if is_ajax():
                result = render('/util/delete_accept_partial.html')
            else:
                result = render('/util/delete_accept.html')
            return result
Exemple #11
0
    def edit(self, id):
        node = self._get_row(model.Report, id)
        event_node = node.event
        self._check_access(event_node)

        fs = ReportForm('report-edit')

        if request.POST and fs.fields.cancel.id in request.POST:
            if self.back_page():
                return redirect_to(**self.back_page())
            return redirect_to(node.url())

        if request.POST and fs.is_valid(request.POST):

            node.title = fs.fields.title.value
            node.content = fs.fields.content.value

            meta.Session.commit()
            flash(u'Отчет успешно сохранен')
            if fs.fields.save_view.id in request.POST:
                return redirect_to(node.url())
            elif fs.fields.save_view_event.id in request.POST:
                return redirect_to(event_node.url())

        if not request.POST:
            fs.set_values({
                'title': node.title,
                'content': node.content
            })

        c.form = fs
        c.fs = fs.fields
        c.node = node

        if is_ajax():
            result = render('/report/edit_partial.html')
        else:
            result = render('/report/edit.html')
        return fs.htmlfill(result)
Exemple #12
0
    def remove(self, id):
        node = self._get_row(model.Album, id)
        event_node = node.event
        self._check_access(event_node)

        fs = form.DeleteAcceptForm('album-remove')

        if request.POST:
            if fs.fields.save.id in request.POST:
                meta.Session.delete(node)
                meta.Session.commit()
                flash(u'Альбом успешно удален')
            if self.back_page():
                return redirect_to(**self.back_page())
            return redirect_to(event_node.url())
        else:
            c.form = fs
            if is_ajax():
                result = render('/util/delete_accept_partial.html')
            else:
                result = render('/util/delete_accept.html')
            return result
Exemple #13
0
    def edit(self, id):
        node = self._get_row(model.Person, id)
        event_node = node.event
        self._check_access(event_node)

        fs = PersonForm('person-edit')

        if request.POST and fs.fields.cancel.id in request.POST:
            return self._redirect_to_default(event_node.id)

        if request.POST and fs.is_valid(request.POST):
            node.fullname = fs.fields.fullname.value

            if fs.fields.avatar.value is not None:
                node.avatar = avatar_prepare(fs.fields.avatar.value.file)

            meta.Session.add(node)
            event_node.persons.append(node)
            meta.Session.commit()
            flash(u'Учасник успешно сохранен')
            if self.back_page():
                return redirect_to(**self.back_page())
            return redirect_to(event_node.url())

        if not request.POST:
            fs.set_values({
                'fullname': node.fullname,
                'avatar': node.avatar
            })

        c.node = node
        c.form = fs
        c.fs = fs.fields

        if is_ajax():
            result = render('/person/edit_partial.html')
        else:
            result = render('/person/edit.html')
        return fs.htmlfill(result)
Exemple #14
0
    def edit(self, id):
        node = self._get_row(model.Event, id)
        self._check_access(node)

        fs = EventForm('event-edit')

        if request.POST and fs.fields.cancel.id in request.POST:
            return redirect_to(node.url())

        if request.POST and fs.is_valid(request.POST):
            node.title = fs.fields.title.value
            node.summary = fs.fields.summary.value
            node.start = fs.fields.start.value
            node.finish = fs.fields.finish.value

            meta.Session.commit()
            flash(u'Информация о событии успешно сохранена')
            if self.back_page():
                return redirect_to(**self.back_page())
            return redirect_to(node.url())

        if not request.POST:
            fs.set_values({
                'title': node.title,
                'start': node.start.strftime(DATE_FORMAT),
                'finish': node.finish.strftime(DATE_FORMAT),
                'summary': node.summary
            })

        c.node = node
        c.form = fs
        c.fs = fs.fields

        if is_ajax():
            result = render('/event/edit_partial.html')
        else:
            result = render('/event/edit.html')
        return fs.htmlfill(result)
Exemple #15
0
    def publish(self, id, published):
        node = self._get_row(model.Event, id)
        self._check_access(node)

        if published == '1':
            node.published = datetime.now()
            message = u'Событие успешно опубликовано'
        else:
            node.published = None
            message = u'Событие успешно сохранено как черновик'

        meta.Session.commit()
        flash(message)
        return redirect_to(node.url())
Exemple #16
0
    def new(self, event_id):
        event_node = self._get_row(model.Event, event_id)
        self._check_access(event_node)

        fs = ReportForm('report-new')

        if request.POST and fs.fields.cancel.id in request.POST:
            return redirect_to(event_node.url())

        if request.POST and fs.is_valid(request.POST):
            node = model.Report()
            node.title = fs.fields.title.value
            node.content = fs.fields.content.value
            node.event = event_node
            node.node_user_id = current_user().id

            meta.Session.add(node)
            meta.Session.commit()
            flash(u'Отчет успешно добавлен')
            if fs.fields.save_view.id in request.POST:
                return redirect_to(node.url())
            elif fs.fields.save_view_event.id in request.POST:
                return redirect_to(event_node.url())
            else:
                return redirect_to(node.url_edit())


        c.form = fs
        c.fs = fs.fields

        if is_ajax():
            result = render('/report/new_partial.html')
        else:
            result = render('/report/new.html')
        if request.POST:
            result = fs.htmlfill(result)
        return result
Exemple #17
0
    def new(self, event_id):
        event_node = self._get_row(model.Event, event_id)
        self._check_access(event_node)

        fs = ReportForm('report-new')

        if request.POST and fs.fields.cancel.id in request.POST:
            return redirect_to(event_node.url())

        if request.POST and fs.is_valid(request.POST):
            node = model.Report()
            node.title = fs.fields.title.value
            node.content = fs.fields.content.value
            node.event = event_node
            node.node_user_id = current_user().id

            meta.Session.add(node)
            meta.Session.commit()
            flash(u'Отчет успешно добавлен')
            if fs.fields.save_view.id in request.POST:
                return redirect_to(node.url())
            elif fs.fields.save_view_event.id in request.POST:
                return redirect_to(event_node.url())
            else:
                return redirect_to(node.url_edit())

        c.form = fs
        c.fs = fs.fields

        if is_ajax():
            result = render('/report/new_partial.html')
        else:
            result = render('/report/new.html')
        if request.POST:
            result = fs.htmlfill(result)
        return result
Exemple #18
0
    def new(self, event_id):
        event_node = self._get_row(model.Event, event_id)
        self._check_access(event_node)

        fs = PersonForm('person-new')

        if request.POST and fs.fields.cancel.id in request.POST:
            return self._redirect_to_default(event_node.id)

        if request.POST and fs.is_valid(request.POST):
            node = model.Person()
            node.fullname = fs.fields.fullname.value
            node.event = event_node

            if fs.fields.avatar.value is not None:
                node.avatar = avatar_prepare(fs.fields.avatar.value.file)

            node.node_user_id = current_user().id

            meta.Session.add(node)
            meta.Session.commit()
            flash(u'Участник успешно добавлен')
            if self.back_page():
                return redirect_to(**self.back_page())
            return redirect_to(event_node.url())

        c.form = fs
        c.fs = fs.fields

        if is_ajax():
            result = render('/person/new_partial.html')
        else:
            result = render('/person/new.html')
        if request.POST:
            result = fs.htmlfill(result)
        return result
Exemple #19
0
    def edit(self, id):
        node = self._get_row(model.Report, id)
        event_node = node.event
        self._check_access(event_node)

        fs = ReportForm('report-edit')

        if request.POST and fs.fields.cancel.id in request.POST:
            if self.back_page():
                return redirect_to(**self.back_page())
            return redirect_to(node.url())

        if request.POST and fs.is_valid(request.POST):

            node.title = fs.fields.title.value
            node.content = fs.fields.content.value

            meta.Session.commit()
            flash(u'Отчет успешно сохранен')
            if fs.fields.save_view.id in request.POST:
                return redirect_to(node.url())
            elif fs.fields.save_view_event.id in request.POST:
                return redirect_to(event_node.url())

        if not request.POST:
            fs.set_values({'title': node.title, 'content': node.content})

        c.form = fs
        c.fs = fs.fields
        c.node = node

        if is_ajax():
            result = render('/report/edit_partial.html')
        else:
            result = render('/report/edit.html')
        return fs.htmlfill(result)
Exemple #20
0
    def new(self, label=None):

        fs = ArticleForm('article-new')

        if request.POST and fs.fields.cancel.id in request.POST:
            if label is not None:
                return redirect_to(label)
            return redirect_to('articles')

        if request.POST and fs.is_valid(request.POST):
            node = model.Article()
            node.title = fs.fields.title.value
            node.content = fs.fields.content.value
            node.label = label
            node.node_user_id = current_user().id

            is_valid = True
            if not fs.fields.path.value:
                fs.fields.path.value = translit.slugify(node.title)
                is_valid = fs.is_valid(fs.get_values(use_ids=True))

            if is_valid:
                node.path = fs.fields.path.value

                meta.Session.add(node)
                meta.Session.commit()

                if fs.fields.save_view.id in request.POST:
                    return redirect_to(node.url())
                elif fs.fields.save_view_list.id in request.POST:
                    if node.label is not None:
                        return redirect_to(node.label)
                    return redirect_to('articles')
                else:
                    return redirect_to(node.url_edit())

        c.form = fs
        c.fs = fs.fields

        if is_ajax():
            result = render('/article/new_partial.html')
        else:
            result = render('/article/new.html')
        if request.POST:
            result = fs.htmlfill(result)
        return result
Exemple #21
0
    def new(self, label=None):

        fs = ArticleForm("article-new")

        if request.POST and fs.fields.cancel.id in request.POST:
            if label is not None:
                return redirect_to(label)
            return redirect_to("articles")

        if request.POST and fs.is_valid(request.POST):
            node = model.Article()
            node.title = fs.fields.title.value
            node.content = fs.fields.content.value
            node.label = label
            node.node_user_id = current_user().id

            is_valid = True
            if not fs.fields.path.value:
                fs.fields.path.value = translit.slugify(node.title)
                is_valid = fs.is_valid(fs.get_values(use_ids=True))

            if is_valid:
                node.path = fs.fields.path.value

                meta.Session.add(node)
                meta.Session.commit()

                if fs.fields.save_view.id in request.POST:
                    return redirect_to(node.url())
                elif fs.fields.save_view_list.id in request.POST:
                    if node.label is not None:
                        return redirect_to(node.label)
                    return redirect_to("articles")
                else:
                    return redirect_to(node.url_edit())

        c.form = fs
        c.fs = fs.fields

        if is_ajax():
            result = render("/article/new_partial.html")
        else:
            result = render("/article/new.html")
        if request.POST:
            result = fs.htmlfill(result)
        return result