Пример #1
0
def set_delegate_positions(request, conference):
    if request.method == "POST":
        form = jEditableForm(data=request.POST)
        if form.is_valid():
            # get the committee and country PK
            raw_id = request.POST.get("id", "")
            committee_pk, country_pk = raw_id.rsplit("_")
            if country_pk and committee_pk:
                committee = get_object_or_404(Committee, pk=committee_pk)
                country = get_object_or_404(Country, pk=country_pk)
                value = form.cleaned_data["value"]
                if committee.conference == conference and country.conference == conference and value:
                    if value == "":
                        value = "0"
                    new_count = int(value)
                    country_positions = []
                    current_positions = DelegatePosition.objects.filter(committee=committee, country=country)
                    if len(current_positions) < new_count:
                        country_positions = DelegatePosition.objects.filter(country=country)
                    set_delegate_position_count(
                        committee,
                        country,
                        current_positions,
                        get_school_from_position_set(country_positions),
                        new_count,
                    )
                    return HttpResponse(value)
Пример #2
0
def set_delegate_positions(request, conference):
    if request.method == 'POST':
        form = jEditableForm(data=request.POST)
        if form.is_valid():
            # get the committee and country PK
            raw_id = request.POST.get('id', '')
            committee_pk, country_pk = raw_id.rsplit("_")
            if country_pk and committee_pk:
                committee = get_object_or_404(Committee, pk=committee_pk)
                country = get_object_or_404(Country, pk=country_pk)
                value = form.cleaned_data['value']
                if committee.conference == conference and country.conference == conference and value:
                    if value == "":
                        value = "0"
                    new_count = int(value)
                    country_positions = []
                    current_positions = DelegatePosition.objects.filter(
                        committee=committee, country=country)
                    if len(current_positions) < new_count:
                        country_positions = DelegatePosition.objects.filter(
                            country=country)
                    set_delegate_position_count(
                        committee, country, current_positions,
                        get_school_from_position_set(country_positions),
                        new_count)
                    return HttpResponse(value)
Пример #3
0
def edit_payment(request, conference):
    # clean the POST data
    if request.method == 'POST':
        form = jEditableForm(data=request.POST)
        if form.is_valid():
            # get the payment PK and attribute we want to set. The id is formatted "attr_pk"
            raw_id = request.POST.get('id', '')
            payment_attr, payment_pk = raw_id.rsplit("_")
            if payment_attr and payment_pk:
                payment = get_object_or_404(Payment, pk=payment_pk)
                value = form.cleaned_data['value']
                if payment.conference == conference and value:
                    payment.__setattr__(payment_attr, value)
                    payment.save()
                    return HttpResponse(value)
Пример #4
0
def edit_country(request, conference):
    # clean the POST data
    if request.method == 'POST':
        form = jEditableForm(data=request.POST)
        if form.is_valid():
            # get the country PK and attribute we want to set. The id is formatted "attr_pk"
            raw_id = request.POST.get('id', '')
            country_attr, country_pk = raw_id.rsplit("_")
            if country_attr and country_pk:
                country = get_object_or_404(Country, pk=country_pk)
                value = form.cleaned_data['value']
                if country.conference == conference and value:
                    country.__setattr__(country_attr, value)
                    country.save()
                    return HttpResponse(value)
Пример #5
0
def edit_payment(request, conference):
    # clean the POST data
    if request.method == "POST":
        form = jEditableForm(data=request.POST)
        if form.is_valid():
            # get the payment PK and attribute we want to set. The id is formatted "attr_pk"
            raw_id = request.POST.get("id", "")
            payment_attr, payment_pk = raw_id.rsplit("_")
            if payment_attr and payment_pk:
                payment = get_object_or_404(Payment, pk=payment_pk)
                value = form.cleaned_data["value"]
                if payment.conference == conference and value:
                    payment.__setattr__(payment_attr, value)
                    payment.save()
                    return HttpResponse(value)
Пример #6
0
def edit_country(request, conference):
    # clean the POST data
    if request.method == "POST":
        form = jEditableForm(data=request.POST)
        if form.is_valid():
            # get the country PK and attribute we want to set. The id is formatted "attr_pk"
            raw_id = request.POST.get("id", "")
            country_attr, country_pk = raw_id.rsplit("_")
            if country_attr and country_pk:
                country = get_object_or_404(Country, pk=country_pk)
                value = form.cleaned_data["value"]
                if country.conference == conference and value:
                    country.__setattr__(country_attr, value)
                    country.save()
                    return HttpResponse(value)
Пример #7
0
def edit_committee(request, conference):
    # clean the POST data
    if request.method == 'POST':
        form = jEditableForm(data=request.POST)
        if form.is_valid():
            # get the committee PK and attribute we want to set. The id is formatted "attr_pk"
            raw_id = request.POST.get('id', '')
            committee_attr, committee_pk = raw_id.rsplit("_")
            if committee_attr and committee_pk:
                committee = get_object_or_404(Committee, pk=committee_pk)
                value = form.cleaned_data['value']
                if committee.conference == conference and value:
                    committee.__setattr__(committee_attr, value)
                    committee.save()
                    return HttpResponse(value)
Пример #8
0
def set_country_school_assignments(request, conference):
    if request.method == 'POST':
        form = jEditableForm(data=request.POST)
        if form.is_valid():
            country_pk = request.POST.get('id', '')
            country = get_object_or_404(Country, pk=country_pk)
            if country.conference == conference:
                country_positions = DelegatePosition.objects.filter(country=country)
                school_pk = form.cleaned_data['value']
                if school_pk == "-1":
                    set_country_school_assignment(country_positions, None)
                    return HttpResponse(" ")
                else:
                    school = get_object_or_404(School, pk=school_pk)
                    if is_school_registered(conference, school):
                        set_country_school_assignment(country_positions, school)
                        return HttpResponse(school.name)
Пример #9
0
def set_country_school_assignments(request, conference):
    if request.method == "POST":
        form = jEditableForm(data=request.POST)
        if form.is_valid():
            country_pk = request.POST.get("id", "")
            country = get_object_or_404(Country, pk=country_pk)
            if country.conference == conference:
                country_positions = DelegatePosition.objects.filter(country=country)
                school_pk = form.cleaned_data["value"]
                if school_pk == "-1":
                    set_country_school_assignment(country_positions, None)
                    return HttpResponse(" ")
                else:
                    school = get_object_or_404(School, pk=school_pk)
                    if is_school_registered(conference, school):
                        set_country_school_assignment(country_positions, school)
                        return HttpResponse(school.name)
Пример #10
0
def set_individual_delegate_positions(request, conference):
    if request.method == 'POST':
        form = jEditableForm(data=request.POST)
        if form.is_valid():
            position_id = request.POST.get('id', '')
            classes = request.POST.get('row_class', '')
            value = form.cleaned_data['value']
            position = get_object_or_404(DelegatePosition, pk=position_id)
            if position.country.conference == conference:
                if "title" in classes and len(value) > 0:
                    position.title = value
                    position.save()
                    return HttpResponse(position.title)
                elif "country" in classes:
                    country = get_object_or_404(Country, pk=value)
                    if country.conference == conference:
                        position.country = country
                        position.save()
                        return HttpResponse(country.name)
                elif "committee" in classes:
                    committee = get_object_or_404(Committee, pk=value)
                    if committee.conference == conference:
                        position.committee = committee
                        position.save()
                        return HttpResponse(committee.name)
                elif "school" in classes:
                    if value == "-1":
                        position.school = None
                        position.save()
                        return HttpResponse("")
                    else:
                        school = get_object_or_404(School, pk=value)
                        if is_school_registered(conference, school):
                            position.school = school
                            position.save()
                            return HttpResponse(school.name)
Пример #11
0
def set_individual_delegate_positions(request, conference):
    if request.method == "POST":
        form = jEditableForm(data=request.POST)
        if form.is_valid():
            position_id = request.POST.get("id", "")
            classes = request.POST.get("row_class", "")
            value = form.cleaned_data["value"]
            position = get_object_or_404(DelegatePosition, pk=position_id)
            if position.country.conference == conference:
                if "title" in classes and len(value) > 0:
                    position.title = value
                    position.save()
                    return HttpResponse(position.title)
                elif "country" in classes:
                    country = get_object_or_404(Country, pk=value)
                    if country.conference == conference:
                        position.country = country
                        position.save()
                        return HttpResponse(country.name)
                elif "committee" in classes:
                    committee = get_object_or_404(Committee, pk=value)
                    if committee.conference == conference:
                        position.committee = committee
                        position.save()
                        return HttpResponse(committee.name)
                elif "school" in classes:
                    if value == "-1":
                        position.school = None
                        position.save()
                        return HttpResponse("")
                    else:
                        school = get_object_or_404(School, pk=value)
                        if is_school_registered(conference, school):
                            position.school = school
                            position.save()
                            return HttpResponse(school.name)