Example #1
0
def _ik_chpasswd_handle_valid_form(request, form):
    oldpw = form.cleaned_data['old_password']
    newpw = form.cleaned_data['new_password']
    giedo.change_password(str(request.user.name), oldpw, newpw)
    t = _("""Lieve %s, maar natuurlijk, jouw wachtwoord is veranderd.""")
    messages.info(request, t % request.user.first_name)
    return HttpResponseRedirect(reverse('smoelen-home'))
Example #2
0
def _ik_chpasswd_handle_valid_form(request, form):
    oldpw = form.cleaned_data["old_password"]
    newpw = form.cleaned_data["new_password"]
    giedo.change_password(str(request.user.name), oldpw, newpw)
    t = _("""Lieve %s, maar natuurlijk, jouw wachtwoord is veranderd.""")
    messages.info(request, t % request.user.first_name)
    return HttpResponseRedirect(reverse("smoelen-home"))
Example #3
0
def _ik_chpasswd_handle_valid_form(request, form):
    oldpw = form.cleaned_data['old_password']
    newpw = form.cleaned_data['new_password']
    giedo.change_password(str(request.user.name), oldpw, newpw)
    t = """Lieve %s, maar natuurlijk, jouw wachtwoord is veranderd."""
    request.user.push_message(t % request.user.first_name)
    return HttpResponseRedirect(reverse('smoelen-home'))
Example #4
0
def user_reset_password(request, _id):
    if not "secretariaat" in request.user.cached_groups_names:
        raise PermissionDenied
    u = Es.by_id(_id).as_user()
    if not u.is_active:
        raise ValueError, _("Gebruiker is niet geactiveerd")
    pwd = pseudo_randstr()
    u.set_password(pwd)
    giedo.change_password(str(u.name), pwd, pwd)
    render_then_email("leden/reset-password.mail.txt", u, {"user": u, "password": pwd})
    messages.info(request, _("Wachtwoord gereset!"))
    return redirect_to_referer(request)
Example #5
0
def user_reset_password(request, _id):
    if not 'secretariaat' in request.user.cached_groups_names:
        raise PermissionDenied
    u = Es.by_id(_id).as_user()
    pwd = pseudo_randstr()
    u.set_password(pwd)
    giedo.change_password(str(u.name), pwd, pwd)
    render_then_email("leden/reset-password.mail.txt",
                        u.canonical_full_email, {
                            'user': u,
                            'password': pwd})
    request.user.push_message("Wachtwoord gereset!")
    return redirect_to_referer(request)
Example #6
0
def user_reset_password(request, _id):
    if not 'secretariaat' in request.user.cached_groups_names:
        raise PermissionDenied
    u = Es.by_id(_id).as_user()
    pwd = pseudo_randstr()
    u.set_password(pwd)
    giedo.change_password(str(u.name), pwd, pwd)
    render_then_email("leden/reset-password.mail.txt",
                        u.canonical_full_email, {
                            'user': u,
                            'password': pwd})
    request.user.push_message("Wachtwoord gereset!")
    return redirect_to_referer(request)
Example #7
0
def ik_openvpn(request):
    password_incorrect = False
    if "want" in request.POST and "password" in request.POST:
        # TODO password versions
        if request.user.check_password(request.POST["password"]):
            giedo.change_password(str(request.user.name), request.POST["password"], request.POST["password"])
            giedo.openvpn_create(str(request.user.name), request.POST["want"])
            messages.info(request, _("Je verzoek wordt verwerkt. " "Verwacht binnen 5 minuten een e-mail."))
            return HttpResponseRedirect(reverse("smoelen-home"))
        else:
            password_incorrect = True
    return render_to_response(
        "leden/ik_openvpn.html", {"password_incorrect": password_incorrect}, context_instance=RequestContext(request)
    )
Example #8
0
def user_reset_password(request, _id):
    if 'secretariaat' not in request.user.cached_groups_names:
        raise PermissionDenied
    u = Es.by_id(_id).as_user()
    if not u.is_active:
        raise ValueError(_("Gebruiker is niet geactiveerd"))
    pwd = pseudo_randstr()
    u.set_password(pwd)
    giedo.change_password(str(u.name), pwd, pwd)
    render_then_email("leden/reset-password.mail.html", u, {
        'user': u,
        'password': pwd
    })
    messages.info(request, _("Wachtwoord gereset!"))
    return redirect_to_referer(request)
Example #9
0
def ik_openvpn(request):
    password_incorrect = False
    if 'want' in request.POST and 'password' in request.POST:
        # TODO password versions
        if request.user.check_password(request.POST['password']):
            giedo.change_password(str(request.user.name),
                    request.POST['password'],
                    request.POST['password'])
            giedo.openvpn_create(str(request.user.name),
                    request.POST['want'])
            request.user.push_message("Je verzoek wordt verwerkt. "+
                "Verwacht binnen 5 minuten een e-mail.")
            return HttpResponseRedirect(reverse('smoelen-home'))
        else:
            password_incorrect = True
    return render_to_response('leden/ik_openvpn.html',
            {'password_incorrect': password_incorrect},
            context_instance=RequestContext(request))
Example #10
0
def ik_openvpn(request):
    password_incorrect = False
    if 'want' in request.POST and 'password' in request.POST:
        # TODO password versions
        if request.user.check_password(request.POST['password']):
            giedo.change_password(str(request.user.name),
                    request.POST['password'],
                    request.POST['password'])
            giedo.openvpn_create(str(request.user.name),
                    request.POST['want'])
            request.user.push_message("Je verzoek wordt verwerkt. "+
                "Verwacht binnen 5 minuten een e-mail.")
            return HttpResponseRedirect(reverse('smoelen-home'))
        else:
            password_incorrect = True
    return render_to_response('leden/ik_openvpn.html',
            {'password_incorrect': password_incorrect},
            context_instance=RequestContext(request))
Example #11
0
def user_reset_password(request, _id):
    if not 'secretariaat' in request.user.cached_groups_names:
        raise PermissionDenied
    u = Es.by_id(_id).as_user()
    pwd = pseudo_randstr()
    u.set_password(pwd)
    giedo.change_password(str(u.name), pwd, pwd)
    email = EmailMessage(
        "[KN] Nieuw wachtwoord",
        ("Beste %s,\n\n"+
         "Jouw wachtwoord is gereset.  Je kunt inloggen met:\n"+
         "  gebruikersnaam     %s\n"+
         "  wachtwoord         %s\n\n"+
         "Met een vriendelijke groet,\n\n"+
         "  Het Karpe Noktem Smoelenboek") % (
              u.first_name, str(u.name), pwd),
        'Karpe Noktem\'s ledenadministratie <*****@*****.**>',
        [u.canonical_email])
    email.send()
    request.user.push_message("Wachtwoord gereset!")
    return redirect_to_referer(request)
Example #12
0
def secr_add_user(request):
    if 'secretariaat' not in request.user.cached_groups_names:
        raise PermissionDenied
    if request.method == 'POST':
        form = AddUserForm(request.POST)
        if form.is_valid():
            fd = form.cleaned_data
            # First, create the entity.
            u = Es.User({
                'types': ['user'],
                'names': [fd['username']],
                'humanNames': [{
                    'human':
                    fd['first_name'] + ' ' + fd['last_name']
                }],
                'person': {
                    'titles': [],
                    'nick': fd['first_name'],
                    'given': None,
                    'family': fd['last_name'],
                    'dateOfBirth': date_to_dt(fd['dateOfBirth'])
                },
                'email':
                fd['email'],
                'address': {
                    'street': fd['addr_street'],
                    'number': fd['addr_number'],
                    'zip': fd['addr_zip'],
                    'city': fd['addr_city']
                },
                'telephone':
                fd['telephone'],
                'studies': [{
                    'institute': _id(fd['study_inst']),
                    'study': _id(fd['study']),
                    'from': DT_MIN,
                    'until': DT_MAX,
                    'number': fd['study_number']
                }],
                'is_active':
                True,
                'password':
                None
            })
            logging.info("Added user %s" % fd['username'])
            u.save()
            # Then, add the relations.
            groups = ['leden']
            if fd['incasso']:
                groups.append('incasso')
            else:
                groups.append('geen-incasso')
            for group in groups:
                Es.add_relation(u,
                                Es.id_by_name(group, use_cache=True),
                                _from=date_to_dt(fd['dateJoined']))
            for l in fd['addToList']:
                Es.add_relation(u,
                                Es.id_by_name(l, use_cache=True),
                                _from=now())
            # Let giedo synch. to create the e-mail adresses, unix user, etc.
            # TODO use giedo.async() and let giedo send the welcome e-mail
            giedo.sync()
            # Create a new password and send it via e-mail
            pwd = pseudo_randstr()
            u.set_password(pwd)
            giedo.change_password(str(u.name), pwd, pwd)
            render_then_email("leden/set-password.mail.html", u, {
                'user': u,
                'password': pwd
            })
            # Send the welcome e-mail
            render_then_email("leden/welcome.mail.html", u, {'u': u})
            Es.notify_informacie('adduser', request.user, entity=u._id)
            return HttpResponseRedirect(
                reverse('user-by-name', args=(fd['username'], )))
    else:
        form = AddUserForm()
    return render(request, 'leden/secr_add_user.html', {'form': form})
Example #13
0
def secr_add_user(request):
    if 'secretariaat' not in request.user.cached_groups_names:
        raise PermissionDenied
    if request.method == 'POST':
        form = AddUserForm(request.POST)
        if form.is_valid():
            fd = form.cleaned_data
            # First, create the entity.
            u = Es.User({
                'types': ['user'],
                'names': [fd['username']],
                'humanNames': [{'human': fd['first_name'] + ' ' +
                                fd['last_name']}],
                'person': {
                    'titles': [],
                    'nick': fd['first_name'],
                    'given': None,
                    'family': fd['last_name'],
                    'dateOfBirth': date_to_dt(
                        fd['dateOfBirth'])
                },
                'emailAddresses': [
                    {'email': fd['email'],
                     'from': DT_MIN,
                     'until': DT_MAX}],
                'addresses': [
                    {'street': fd['addr_street'],
                     'number': fd['addr_number'],
                     'zip': fd['addr_zip'],
                     'city': fd['addr_city'],
                     'from': DT_MIN,
                     'until': DT_MAX}],
                'telephones': [
                    {'number': fd['telephone'],
                     'from': DT_MIN,
                     'until': DT_MAX}],
                'studies': [
                    {'institute': _id(fd['study_inst']),
                     'study': _id(fd['study']),
                     'from': DT_MIN,
                     'until': DT_MAX,
                     'number': fd['study_number']}],
                'is_active': True,
                'password': None
            })
            logging.info("Added user %s" % fd['username'])
            u.save()
            # Then, add the relations.
            groups = ['leden']
            if fd['incasso']:
                groups.append('incasso')
            else:
                groups.append('geen-incasso')
            for group in groups:
                Es.add_relation(u, Es.id_by_name(group,
                                                 use_cache=True),
                                _from=date_to_dt(fd['dateJoined']))
            for l in fd['addToList']:
                Es.add_relation(u, Es.id_by_name(l, use_cache=True),
                                _from=now())
            # Let giedo synch. to create the e-mail adresses, unix user, etc.
            # TODO use giedo.async() and let giedo send the welcome e-mail
            giedo.sync()
            # Create a new password and send it via e-mail
            pwd = pseudo_randstr()
            u.set_password(pwd)
            giedo.change_password(str(u.name), pwd, pwd)
            render_then_email("leden/set-password.mail.txt", u, {
                'user': u,
                'password': pwd})
            # Send the welcome e-mail
            render_then_email("leden/welcome.mail.txt", u, {
                'u': u})
            Es.notify_informacie('adduser', request.user, entity=u._id)
            return HttpResponseRedirect(reverse('user-by-name',
                                                args=(fd['username'],)))
    else:
        form = AddUserForm()
    return render_to_response('leden/secr_add_user.html',
                              {'form': form},
                              context_instance=RequestContext(request))
Example #14
0
def secr_add_user(request):
    if "secretariaat" not in request.user.cached_groups_names:
        raise PermissionDenied
    if request.method == "POST":
        form = AddUserForm(request.POST)
        if form.is_valid():
            fd = form.cleaned_data
            # First, create the entity.
            u = Es.User(
                {
                    "types": ["user"],
                    "names": [fd["username"]],
                    "humanNames": [{"human": fd["first_name"] + " " + fd["last_name"]}],
                    "person": {
                        "titles": [],
                        "nick": fd["first_name"],
                        "given": None,
                        "family": fd["last_name"],
                        "gender": fd["gender"],
                        "dateOfBirth": date_to_dt(fd["dateOfBirth"]),
                    },
                    "emailAddresses": [{"email": fd["email"], "from": DT_MIN, "until": DT_MAX}],
                    "addresses": [
                        {
                            "street": fd["addr_street"],
                            "number": fd["addr_number"],
                            "zip": fd["addr_zip"],
                            "city": fd["addr_city"],
                            "from": DT_MIN,
                            "until": DT_MAX,
                        }
                    ],
                    "telephones": [{"number": fd["telephone"], "from": DT_MIN, "until": DT_MAX}],
                    "studies": [
                        {
                            "institute": _id(fd["study_inst"]),
                            "study": _id(fd["study"]),
                            "from": DT_MIN,
                            "until": DT_MAX,
                            "number": fd["study_number"],
                        }
                    ],
                    "is_active": True,
                    "password": None,
                }
            )
            logging.info("Added user %s" % fd["username"])
            u.save()
            # Then, add the relations.
            groups = ["leden"]
            groups.append({"m": "mannen", "v": "vrouwen"}.get(fd["gender"]))
            if fd["incasso"]:
                groups.append("incasso")
            else:
                groups.append("geen-incasso")
            for group in groups:
                Es.add_relation(u, Es.id_by_name(group, use_cache=True), _from=date_to_dt(fd["dateJoined"]))
            for l in fd["addToList"]:
                Es.add_relation(u, Es.id_by_name(l, use_cache=True), _from=now())
            # Let giedo synch. to create the e-mail adresses, unix user, etc.
            # TODO use giedo.async() and let giedo send the welcome e-mail
            giedo.sync()
            # Create a new password and send it via e-mail
            pwd = pseudo_randstr()
            u.set_password(pwd)
            giedo.change_password(str(u.name), pwd, pwd)
            render_then_email("leden/set-password.mail.txt", u, {"user": u, "password": pwd})
            # Send the welcome e-mail
            render_then_email("leden/welcome.mail.txt", u, {"u": u})
            Es.notify_informacie("adduser", request.user, entity=u._id)
            return HttpResponseRedirect(reverse("user-by-name", args=(fd["username"],)))
    else:
        form = AddUserForm()
    return render_to_response("leden/secr_add_user.html", {"form": form}, context_instance=RequestContext(request))