Exemplo n.º 1
0
def create(request):
    if request.method == 'POST':
        party = Party()
        form = PartyForm(request.POST, instance=party)
        if form.is_valid():
            form.save()
            form.log_creation(request.user)

            if request.is_ajax():
                return HttpResponse('OK: %s' % party.get_absolute_url(),
                                    content_type='text/plain')
            else:
                messages.success(request, 'Party added')
                return redirect('party', party.id)
    else:
        form = PartyForm(
            initial={
                'name': request.GET.get('name'),
                'party_series_name': request.GET.get('party_series_name'),
                'scene_org_folder': request.GET.get('scene_org_folder'),
            })
    return render(
        request, 'parties/create.html', {
            'form': form,
            'party_series_names':
            [ps.name for ps in PartySeries.objects.all()],
        })
Exemplo n.º 2
0
def create(request):
	if request.method == 'POST':
		party = Party()
		form = PartyForm(request.POST, instance=party)
		if form.is_valid():
			form.save()
			form.log_creation(request.user)

			if request.is_ajax():
				return HttpResponse('OK: %s' % party.get_absolute_url(), mimetype='text/plain')
			else:
				messages.success(request, 'Party added')
				return redirect('party', args=[party.id])
	else:
		form = PartyForm(initial={
			'name': request.GET.get('name'),
			'party_series_name': request.GET.get('party_series_name'),
			'scene_org_folder': request.GET.get('scene_org_folder'),
		})
	return render(request, 'parties/create.html', {
		'form': form,
		'party_series_names': [ps.name for ps in PartySeries.objects.all()],
	})
Exemplo n.º 3
0
def partido():
    with open('/maladireta/database/partidos.csv') as csv_file:
        csv_reader = csv.reader(csv_file, delimiter=',')
        line_count = 0
        party_count = 0
        leadership_count = 0
        position = Position.objects.search("Presidente de Partido")[0]
        print(position)
        for row in csv_reader:
            if line_count == 0:
                print(f'Column names are {", ".join(row)}')
                line_count += 1
            else:
                if not Party.objects.search(row[1]):
                    print(row[1])
                    party = Party()
                    party.initials = row[1]
                    party.number = row[2]
                    party.name = row[3]
                    party.union = row[4]

                    if row[5]:
                        leadership = Leadership()
                        leadership.name = row[5]
                        leadership.street = row[6]
                        leadership.number = row[7]
                        leadership.neighborhood = row[8]
                        leadership.city = row[9]
                        leadership.state = row[10]
                        leadership.cep = row[11]
                        leadership.note = row[12]
                        leadership.email = row[13]
                        leadership.complement = row[14]
                        leadership.position = position
                        leadership.save()
                        leadership_count += 1
                        party.leadership = Leadership.objects.search(
                            leadership.name)[0]

                    party.save()
                    party_count += 1
    return party_count, leadership_count
Exemplo n.º 4
0
    def test_is_independent(self):
        independent = Party(party_id="ynmp-party:2")
        other = Party(party_id="an:other")

        assert independent.is_independent is True
        assert other.is_independent is False
Exemplo n.º 5
0
def index(request):
    popular_parties = Party.most_popular(10)
    context = {'popular_parties': popular_parties}
    return render(request, 'fulroster/index.html', context)
Exemplo n.º 6
0
def index(request):
    popular_parties = Party.most_popular(10)
    context = {'popular_parties': popular_parties}
    return render(request, 'fulroster/index.html', context)