def short_list():
    registered = defaultdict(list)

    for person_row in database.get_all_persons():
        if person_row["meeting_flags_verified"]:
            p = schema.Person.from_flat(person_row)
            if p.category["registered"]:
                registered[p.category["id"]].append(p)

    meeting = {
        "description": "Sixty-first meeting of the Standing Committee",
        "address": "Geneva (Switzerland), 15-19 August 2011"
    }

    page_info = {
        "title": "Print list of registered participants (verified)",
        "url": "printouts.short_list",
    }

    return {
        "page_info": page_info,
        "registered": registered,
        "registered_total": sum(len(cat) for cat in registered.values()),
        "meeting": meeting
    }
def _person_row_for_printouts(type):
    for person_row in database.get_all_persons():
        p = schema.Person.from_flat(person_row)
        c = p.category
        if not person_row["meeting_flags_%s" % type] or not c["registered"]:
           continue
        yield p
Exemple #3
0
def export():
    all_persons = database.get_all_persons(g.db)
    sorted_dict = collections.defaultdict(list)
    for name, session_key in all_persons:
        sorted_dict[session_key].append(name)
    f = StringIO.StringIO()
    writer = unicode_helper.UnicodeWriter(f)
    for session_key, names in sorted_dict.iteritems():
        names_string = " ".join(names)
        url = config.URL_PREFIX + session_key
        writer.writerow([names_string, config.GREATER_TEXT % url])
    response = make_response(f.getvalue())
    # This is the key: Set the right header for the response
    # to be downloaded, instead of just printed on the browser
    response.headers["Content-Disposition"] = "attachment; filename=export.csv"
    return response
Exemple #4
0
def home():
    categories = defaultdict(int)

    persons = list(database.get_all_persons())
    for person_row in persons:
        person = schema.PersonSchema.from_flat(person_row).value
        categories[person.category["name"]] += 1

    total_count = len(persons)
    for category, count in categories.items():
        categories[category] = (count * 100) / total_count

    categories = sorted(categories.items(), key=lambda x: x[1], reverse=True)
    labels = [c[0] for c in categories ]
    data = [c[1] for c in categories]

    return {
        "data": flask.json.dumps(data),
        "labels": flask.json.dumps(labels),
        "categories": categories,
    }
Exemple #5
0
def rename(selected_person=None):
    if len(request.args.viewkeys()) > 0:
        if "source_name" in request.args:
            source_name = request.args["source_name"]
        else:
            source_name = None
        if "new_name" in request.args:
            new_name = request.args["new_name"]
        else:
            new_name = None
        if "action" in request.args:
            if request.args["action"] == "rename":
                action = "rename"
            else:
                action = None
        else:
            action = None
        if source_name is not None and new_name is not None and action is not None:
            database.rename_person(g.db, source_name, new_name)
        return redirect("/rename")
    persons = map(lambda x: dict(name=x["name"], selected=x["name"]==selected_person), database.get_all_persons(g.db))
    return render_template("rename.html", persons=persons)
Exemple #6
0
def registration():
    people = [(person_row.id, schema.PersonSchema.from_flat(person_row).value)
              for person_row in database.get_all_persons()]
    return {
        "people": people,
    }