示例#1
0
def delete_group(wiki_group):
    wg = WikiGroup.objects(db_name=wiki_group).first()
    if wg is not None:
        if wg.active:
            db_connection_settings.pop(wg.db_name, None)
            disconnect(wg.db_name)
        db.connection.drop_database(wg.db_name)
        wg.delete()

        shutil.rmtree(
            os.path.join(current_app.config['UPLOAD_PATH'], wiki_group))

    return redirect(url_for('.home'))
示例#2
0
def wiki_activate_group(group):
    wg = WikiGroup.objects(name_no_whitespace=group).first()
    if wg is not None:
        if wg.active:
            wg.active = False
            db_connection_settings.pop(group, None)
            disconnect(group)
        else:
            wg.active = True
            db.register_connection(alias=group,
                                   name=group,
                                   host=config.MONGODB_SETTINGS['host'],
                                   port=config.MONGODB_SETTINGS['port'])
        wg.save()
    return redirect(url_for('.wiki_super_admin'))
示例#3
0
def wiki_delete_group(group):
    wg = WikiGroup.objects(name_no_whitespace=group).first()
    if wg is not None:
        if wg.active:
            db_connection_settings.pop(group, None)
            disconnect(group)
        db.connection.drop_database(group)
        wg.delete()
        users = WikiUser.objects.all()
        for u in users:
            if u.permissions:
                u.save()
            else:
                u.delete()
    return redirect(url_for('.wiki_super_admin'))
示例#4
0
def activate(wiki_group):
    wg = WikiGroup.objects(db_name=wiki_group).first()
    if wg is not None:
        if wg.active:
            wg.active = False
            db_connection_settings.pop(wg.db_name, None)
            disconnect(wg.db_name)
        else:
            wg.active = True
            db.register_connection(
                alias=wg.db_name,
                name=wg.db_name,
                host=current_app.config['MONGODB_SETTINGS']['host'],
                port=current_app.config['MONGODB_SETTINGS']['port'])
        wg.save()
    return redirect(url_for('.home'))