Beispiel #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",
                              )
Beispiel #2
0
    for m in Member.objects.filter(user__is_active=False, expires__gte=datetime.date.today()):
        print "The member", m.user, "became active at", m.expires, m.user.first_name, m.user.last_name, "will be activated"
        m.user.is_active = True
        m.user.save()
        request_apache_reload()
        enabled_members.append(m)
        mail_body = render_to_string("email/account_activated.txt", {'member': m})
        try:
            sent = send_mail("Account activated", mail_body, admins_emails[0], [admins_emails[0], m.user.email])
        except Exception, e:
            email_problem = True

    # vcs and dav configs
    share_types = [s[0] for s in SHARE_TYPE_CHOICES]
    for typ in share_types:
        shares = get_shares_to_render(typ)
        for share in shares:
            filename = os.path.join(settings.GENERATE_FOLDER, typ + ".config")
            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)