Ejemplo n.º 1
0
def get_config(request, which):

    is_god = check_god(request)
    if not is_god:
        raise PermissionDenied

    if which == "groups.dav":
        groups = get_groups_to_render()
        return render_to_response('configs/groups.dav', locals(), mimetype="text/plain" )

        pass
    elif not which in share_types:
        return HttpResponse(which + " is a invalid share type. Supported are: " + ", ".join(share_types))

    shares = get_shares_to_render(which)
    return render_to_response('configs/' + which + '.config',
                              {'shares': shares},
                              mimetype="text/plain",
                              )
Ejemplo n.º 2
0
            try:
                with open(filename, "wb") as apache_config_file:
                    apache_config_file.write(render_to_string("configs/" + typ + ".config",
                        {
                            'shares': shares,
                        },))
                    apache_config_file.close()

            except Exception, e:
                error = "Could not write config file " + os.path.abspath(filename) + "\n" + "Exception: " + str(e)
                raise e
                return answer(message=_("There was a problem."), error=error)

    # Apache group file
    filename = os.path.join(settings.GENERATE_FOLDER, "groups.dav")
    groups = get_groups_to_render()
    try:
        with open(filename, "wb") as apache_group_file:
            apache_group_file.write(render_to_string("configs/groups.dav",
                {
                    'groups': groups,
                },))
            apache_group_file.close()
    except Exception, e:
        error = "Could not write config file " + os.path.abspath(filename) + "\n" + "Exception: " + str(e)
        return answer(message=_("There was a problem."), error=error)

    # Apache password file
    filename = os.path.join(settings.GENERATE_FOLDER, "passwd.dav")
    passwd = "\n".join([m.htdigest for m in Member.objects.filter(user__is_active=True)])
    passwd += "\n"