Ejemplo n.º 1
0
def home(request):
    if not request.session.get("saaranguser_email"):
        return redirect("hospi_login")
    email = request.session.get("saaranguser_email")
    user = SaarangUser.objects.get(email=email)
    if not user.profile_is_complete():
        messages.error(
            request,
            "Your profile is not complete. Click <a href='http://saarang.org/2014/main/#profile' target='_blank'>here</a> to update your profile. ",
        )
        return redirect("hospi_prehome")
    if not request.session.get("current_team"):
        return redirect("hospi_prehome")
    team_id = request.session.get("current_team")
    team = get_object_or_404(HospiTeam, pk=team_id)
    if team.members.filter(email=team.leader.email):
        team.members.remove(team.leader)
        messages.warning(request, "Team leader found in members list also. Successfully removed!")
    members = team.members.all()
    msg = ""
    if team.accomodation_status != "confirmed":
        for member in members:
            if member.accomod_is_confirmed:
                msg += member.email + ", "
        if msg:
            messages.warning(
                request,
                msg
                + ": These members already have accommodation \
                confirmed in other team. Please remove them, or they will be automatically \
                removed upon confirmation.",
            )
    edits = ["not_req", "requested"]
    if team.accomodation_status in edits:
        editable = True
    else:
        editable = False
    bill_data = u.bill(
        team.date_of_arrival,
        team.time_of_arrival,
        team.date_of_departure,
        team.time_of_departure,
        team.get_total_count(),
    )
    to_return = {"editable": editable, "leader": user, "team": team, "members": members, "bill_data": bill_data}
    return render(request, "hospi/home.html", to_return)
Ejemplo n.º 2
0
def team_details(request, team_id):
    team = get_object_or_404(HospiTeam, pk=team_id)
    edit_list = ["confirmed", "rejected"]
    leader = team.leader
    bill_data = u.bill(
        team.date_of_arrival,
        team.time_of_arrival,
        team.date_of_departure,
        team.time_of_departure,
        team.get_total_count(),
    )
    if team.accomodation_status in edit_list:
        editable = False
    else:
        editable = True
    to_return = {
        "leader": leader,
        "bill_data": bill_data,
        "addUserForm": SaarangUserForm(),
        "editable": editable,
        "team": team,
    }
    return render(request, "hospi/team_details.html", to_return)