예제 #1
0
파일: views.py 프로젝트: fikander/aolevents
def serialise_events_for_query(
    query, user=None, facebook=False, provide_favourite_state=False, provide_rsvp_state=False
):
    """ only shows active events!
    """

    contents = ""

    query.filter("active =", True)
    query.filter("moderated =", True)

    for e in query:
        if e.name and e.location and e.type:
            if facebook is True:
                absolute_url = e.get_facebook_url()
            else:
                absolute_url = e.get_absolute_url()

            contents_list = [
                "[" + e.country.key().name() + "] " + prepare_for_csv(e.name),
                e.type,
                # numeric value out of type string
                str(e.fields()["type"].make_value_from_form(e.type)),
                # sorting needs nice arranged format...
                e.date_start.strftime("%Y-%m-%d (%a) at %H:%M%Z"),
                e.date_end.strftime("%Y-%m-%d (%a) at %H:%M%Z"),
                # e.date_end.strftime('%a %d %b %Y at %H:%M%Z'),
                # e.date_end.isoformat(' '),
                e.recurrent,
                e.location.__str__(),
                absolute_url,
                str(e.key().id()),
                str(e.featured_priority),
                str(int(e.free)),
            ]

            if provide_favourite_state:
                if user and user.is_authenticated():
                    is_fav = Favourite.all().filter("event =", e).filter("user ="******"event =", e).filter("user ="******",")
            contents += "\n"

    return contents