filtrowanie ogloszen wolontariat

This commit is contained in:
Alicja Kupczyk 2021-01-02 17:05:39 +01:00
parent 0b37ac8be5
commit 981b39b2fb
22 changed files with 30 additions and 68 deletions

View File

@ -1,4 +1,4 @@
# Generated by Django 3.1.4 on 2020-12-20 16:51 # Generated by Django 3.1.4 on 2021-01-02 14:27
import datetime import datetime
from django.conf import settings from django.conf import settings
@ -15,11 +15,20 @@ class Migration(migrations.Migration):
] ]
operations = [ operations = [
migrations.CreateModel(
name='Places',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('city', models.TextField(default='', max_length=40)),
('woj_city', models.TextField(default='', max_length=40)),
],
),
migrations.CreateModel( migrations.CreateModel(
name='Product', name='Product',
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('active', models.BooleanField(default=True)), ('active', models.BooleanField(default=True)),
('Wolontatriat', models.BooleanField(default=False)),
('picture', models.ImageField(blank=True, null=True, upload_to='images/')), ('picture', models.ImageField(blank=True, null=True, upload_to='images/')),
('create_date', models.DateField(default=datetime.date.today, verbose_name='Date')), ('create_date', models.DateField(default=datetime.date.today, verbose_name='Date')),
('type', models.IntegerField(choices=[(1, 'Potrzebuje'), (2, 'Oddam')], default='')), ('type', models.IntegerField(choices=[(1, 'Potrzebuje'), (2, 'Oddam')], default='')),
@ -31,4 +40,13 @@ class Migration(migrations.Migration):
('user_iden', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ('user_iden', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
], ],
), ),
migrations.CreateModel(
name='Ocena',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('comm', models.TextField(default='', max_length=40)),
('ocena_jedn', models.FloatField(default='', max_length=40)),
('user_iden', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
] ]

View File

@ -1,18 +0,0 @@
# Generated by Django 3.1.4 on 2020-12-30 21:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='product',
name='Wolontatriat',
field=models.BooleanField(default=False),
),
]

View File

@ -1,21 +0,0 @@
# Generated by Django 3.1.4 on 2020-12-31 12:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0002_product_wolontatriat'),
]
operations = [
migrations.CreateModel(
name='Places',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('city', models.TextField(default='', max_length=40)),
('woj_city', models.TextField(default='', max_length=40)),
],
),
]

View File

@ -1,25 +0,0 @@
# Generated by Django 3.1.4 on 2021-01-01 16:53
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('homepage', '0003_places'),
]
operations = [
migrations.CreateModel(
name='Ocena',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('comm', models.TextField(default='', max_length=40)),
('ocena_jedn', models.FloatField(default='', max_length=40)),
('user_iden', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]

View File

@ -159,9 +159,12 @@
<h3>Wolontariat</h3> <h3>Wolontariat</h3>
</div> </div>
<ul> <ul>
<label for="Wolontariat">Tak</label> {% if wol_local%}
<p></p> <input type="checkbox" id="wolontariat" name="wolontariat" Checked>
<label for="scales">Nie</label> {% else %}
<input type="checkbox" id="wolontariat" name="wolontariat" >
{% endif %}
<label for="wolontariat">Tak</label>
</ul> </ul>
</aside> </aside>

View File

@ -123,6 +123,8 @@ def filter(request):
potrzebuje_local = request.POST['Potrzebuje'] potrzebuje_local = request.POST['Potrzebuje']
usluga_local = request.POST['usluga'] usluga_local = request.POST['usluga']
przedmiot_local = request.POST['przedmiot'] przedmiot_local = request.POST['przedmiot']
wol_local = request.POST['wolontariat']
if place_local != "": if place_local != "":
@ -143,6 +145,9 @@ def filter(request):
if usluga_local != "on" and przedmiot_local == "on": if usluga_local != "on" and przedmiot_local == "on":
zmienna = 2 zmienna = 2
all_product = all_product.filter(type=zmienna) all_product = all_product.filter(type=zmienna)
if wol_local == "on":
all_product = all_product.filter(Wolontatriat=True)
types = TYPE_T types = TYPE_T