Example #1
0
def _lender_emails(borrow):
    if borrow.state == "ACCEPTED":
        src = borrow.src
        dest = borrow.dest
    else:
        src = accept_station(borrow)
        dest = src
    if src == dest:
        return [account_control.get_email_or_404(src.responsible)]
    else:
        src_email = account_control.get_email_or_404(src.responsible)
        dest_email = account_control.get_email_or_404(dest.responsible)
        return [src_email, dest_email]
Example #2
0
def _borrower_emails(borrow):
    """ Get the email addresses for borrower emails.
    Mail team so they can answer borrower questions and see station changes.
    """
    emails = [] # TODO get team email address
    emails.append(account_control.get_email_or_404(borrow.borrower))
    return emails
Example #3
0
def notify_concerned_remove_request_created(sender, **kwargs):
    rr = kwargs["remove_request"]
    if rr.status != "PENDING":
        return
    email = account_control.get_email_or_404(rr.concerned)
    subject = "team/email/notify_concerned_remove_request_created_subject.txt"
    message = "team/email/notify_concerned_remove_request_created_message.txt"
    send_mail([email], subject, message, kwargs)
Example #4
0
def profile(request):
    account = get_object_or_404(Account, user=request.user)
    email = control.get_email_or_404(account)
    args = { 
        "links" : account.links.all(), "email" : email,
        "has_required_info" : control.has_required_info(account)
    }
    return render_response(request, "account/profile.html", args)
Example #5
0
def notify_concerned_remove_request_created(sender, **kwargs):
    rr = kwargs["remove_request"]
    if rr.status != "PENDING":
        return
    email = account_control.get_email_or_404(rr.concerned)
    subject = "team/email/notify_concerned_remove_request_created_subject.txt"
    message = "team/email/notify_concerned_remove_request_created_message.txt"
    send_mail([email], subject, message, kwargs)
Example #6
0
def profile(request):
    account = get_object_or_404(Account, user=request.user)
    email = control.get_email_or_404(account)
    args = {
        "links": account.links.all(),
        "email": email,
        "has_required_info": control.has_required_info(account)
    }
    return render_response(request, "account/profile.html", args)
Example #7
0
def notify_team_remove_request_processed(sender, **kwargs):
    rr = kwargs["remove_request"]
    if rr.status == "PENDING":
        return
    emails = get_team_emails(rr.team)
    if rr.status == "ACCEPTED":
        emails.append(account_control.get_email_or_404(rr.concerned))
    subject = "team/email/notify_team_remove_request_processed_subject.txt"
    message = "team/email/notify_team_remove_request_processed_message.txt"
    send_mail(emails, subject, message, kwargs)
Example #8
0
def notify_team_remove_request_processed(sender, **kwargs):
    rr = kwargs["remove_request"]
    if rr.status == "PENDING":
        return
    emails = get_team_emails(rr.team)
    if rr.status == "ACCEPTED":
        emails.append(account_control.get_email_or_404(rr.concerned))
    subject = "team/email/notify_team_remove_request_processed_subject.txt"
    message = "team/email/notify_team_remove_request_processed_message.txt"
    send_mail(emails, subject, message, kwargs)
Example #9
0
def view(request, username):
    current_account = get_object_or_404(Account, user=request.user)
    view_account = get_object_or_404(Account, user__username=username)
    if not control.can_view_account(current_account, view_account):
        raise PermissionDenied
    email = control.get_email_or_404(view_account)
    args = { 
        "view_account" : view_account, "links" : view_account.links.all(),
        "email" : email 
    }
    return render_response(request, "account/view.html", args)
Example #10
0
def view(request, username):
    current_account = get_object_or_404(Account, user=request.user)
    view_account = get_object_or_404(Account, user__username=username)
    if not control.can_view_account(current_account, view_account):
        raise PermissionDenied
    email = control.get_email_or_404(view_account)
    args = {
        "view_account": view_account,
        "links": view_account.links.all(),
        "email": email
    }
    return render_response(request, "account/view.html", args)
Example #11
0
def send_reminders_lender_takein():
    today = datetime.datetime.now().date()
    tomorrow = today + datetime.timedelta(days=1)
    borrows = Borrow.objects.filter(
        state="ACCEPTED", finish=tomorrow, reminded_lender_takein=False
    )
    for borrow in borrows:
        email = account_control.get_email_or_404(borrow.dest.responsible)
        subject, message = _get_email_templates("lender", "remind_takein")
        send_mail([email], subject, message, { "borrow" : borrow })
        borrow.reminded_lender_takein = True
        borrow.save()
Example #12
0
def respond(request, team_link, borrow_id):
    team, account, borrow = _get_team_models(request, team_link, borrow_id)
    if request.method == "POST":
        form = forms.Respond(request.POST, borrow=borrow, account=account)
        if form.is_valid():
            control.respond(account, borrow, form.cleaned_data["response"], 
                            form.cleaned_data["note"].strip())
            url = "/%s/borrow/view/%s" % (team.link, borrow.id)
            return HttpResponseRedirect(url)
    else:
        form = forms.Respond(borrow=borrow, account=account)
    email = account_control.get_email_or_404(borrow.borrower)
    args = { 
        "station" : control.accept_station(borrow),
        "email" : email, "links" : borrow.borrower.links.all(),
        "borrow" : borrow, "form" : form, "form_title" : _("BORROW_RESPOND"), 
        "cancel_url" : "/%s/borrow/view/%s" % (team_link, borrow_id)
    }
    return rtr(team, "borrows", request, "borrow/respond.html", args)
Example #13
0
def respond(request, team_link, borrow_id):
    team, account, borrow = _get_team_models(request, team_link, borrow_id)
    if request.method == "POST":
        form = forms.Respond(request.POST, borrow=borrow, account=account)
        if form.is_valid():
            control.respond(account, borrow, form.cleaned_data["response"],
                            form.cleaned_data["note"].strip())
            url = "/%s/borrow/view/%s" % (team.link, borrow.id)
            return HttpResponseRedirect(url)
    else:
        form = forms.Respond(borrow=borrow, account=account)
    email = account_control.get_email_or_404(borrow.borrower)
    args = {
        "station": control.accept_station(borrow),
        "email": email,
        "links": borrow.borrower.links.all(),
        "borrow": borrow,
        "form": form,
        "form_title": _("BORROW_RESPOND"),
        "cancel_url": "/%s/borrow/view/%s" % (team_link, borrow_id)
    }
    return rtr(team, "borrows", request, "borrow/respond.html", args)