Skip to content

Commit c36cdcc

Browse files
committed
refactoring
1 parent 0321b74 commit c36cdcc

13 files changed

+327
-47
lines changed

engine/data/items.csv

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
12,Lo Sturno,Parabita,0,1,1,0,0,0,0,1,0,0,0
1212
14,Skipper Arte Cafè,Fasano,0,1,0,0,0,0,0,0,0,0,0
1313
16,La Super Pizza da Franco,Bari,0,0,1,0,0,0,0,0,0,0,0
14-
17,Capolinea Café,Ceglie Messapica,0,0,1,0,0,0,0,1,0,0,0
14+
17,Capolinea Cafe,Ceglie Messapica,0,0,1,0,0,0,0,1,0,0,0
1515
18,Falsopepe,Massafra,0,1,1,0,0,0,0,0,0,0,0
1616
20,Gaonas Officine del Gusto ,Martina Franca,0,0,1,0,0,0,0,1,0,0,0
1717
21,Miseria e Nobiltà,Alberobello,0,1,1,0,0,0,0,0,0,0,0
@@ -22,7 +22,7 @@
2222
26,La Torre di Merlino,Lecce,0,0,1,0,0,0,0,0,0,0,0
2323
27,Nautilus,Taranto,0,1,0,0,0,0,0,0,0,0,0
2424
28,Le Tagghiate,Lecce,0,0,1,0,0,0,0,0,0,0,0
25-
29,Wunderbar Café,Monopoli,0,1,1,0,0,0,0,0,0,0,0
25+
29,Wunderbar Cafe,Monopoli,0,1,1,0,0,0,0,0,0,0,0
2626
31,Moi Moi,Lecce,0,1,0,0,0,0,0,0,0,0,0
2727
32,Carpe Diem,Gallipoli,0,0,1,0,0,0,0,0,0,0,0
2828
33,Godot food and passion,Lecce,0,0,1,0,0,0,0,1,0,0,0
@@ -4748,5 +4748,5 @@
47484748
8602,Chiostro di San Francesco,Ostuni,0,0,0,0,0,0,0,0,1,0,0
47494749
8603,Masseria Torre Tresca-Resta,Bari,0,0,0,0,0,0,0,0,1,0,0
47504750
8604,Bar Nuove Dimensioni,Crispiano,0,1,1,0,0,1,0,0,0,0,0
4751-
8605,B&B La Grotta Del Re,Grottaglie,0,0,0,0,1,0,0,0,0,0,0
4752-
8606,#Apulia,Ostuni,0,1,1,0,0,1,0,0,0,0,0
4751+
8605,BB La Grotta Del Re,Grottaglie,0,0,0,0,1,0,0,0,0,0,0
4752+
8606,Apulia,Ostuni,0,1,1,0,0,1,0,0,0,0,0

engine/data/model_checkpoint.pickle

3.67 MB
Binary file not shown.

engine/data/ratings_train.csv

+18-20
Original file line numberDiff line numberDiff line change
@@ -2398,23 +2398,21 @@
23982398
10032,757,2
23992399
10032,760,2
24002400
10032,783,1
2401-
10121,827,3
2402-
10121,369,3
2403-
10121,1695,3
2404-
10122,2407,3
2405-
10122,2697,3
2406-
10122,2709,3
2407-
10111,2010,3
2408-
10111,1891,3
2409-
10111,2634,3
2410-
10112,2746,3
2411-
10112,2825,3
2412-
10112,3348,3
2413-
10131,3697,3
2414-
10131,3734,3
2415-
10131,3871,3
2416-
10132,4578,3
2417-
10132,3054,3
2418-
10132,4340,3
2419-
10132,8557,3
2420-
10121,8116,3
2401+
10321,83,3
2402+
10321,84,3
2403+
10321,85,3
2404+
10322,80,3
2405+
10322,81,3
2406+
10322,82,3
2407+
10311,89,3
2408+
10311,90,3
2409+
10311,91,3
2410+
10312,86,3
2411+
10312,87,3
2412+
10312,88,3
2413+
10331,95,3
2414+
10331,96,3
2415+
10331,97,3
2416+
10332,92,3
2417+
10332,93,3
2418+
10332,94,3

engine/data/users.csv

+7-7
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,10 @@
597597
10021,Adelfia,0,3,5,3,5,3,0,2,0,1
598598
10022,Adelfia,0,3,5,3,5,3,0,2,0,1
599599
10031,Adelfia,0,3,5,3,5,3,0,2,0,1
600-
10032,Adelfia,0,3,5,3,5,3,0,2,0,1
601-
10121,Bitonto,0,0,0,0,0,0,0,0,0,0
602-
10122,Bitonto,0,0,0,0,0,0,0,0,0,0
603-
10111,Bitonto,0,0,0,0,0,0,0,0,0,0
604-
10112,Bitonto,0,0,0,0,0,0,0,0,0,0
605-
10131,Bitonto,0,0,0,0,0,0,0,0,0,0
606-
10132,Bitonto,0,0,0,0,0,0,0,0,0,0
600+
10032,Adelfia,0,3,5,3,5,3,0,2,0,1
601+
10321,Santeramo in Colle,0,0,0,0,0,0,0,0,0,0
602+
10322,Santeramo in Colle,0,0,0,0,0,0,0,0,0,0
603+
10311,Santeramo in Colle,0,0,0,0,0,0,0,0,0,0
604+
10312,Santeramo in Colle,0,0,0,0,0,0,0,0,0,0
605+
10331,Santeramo in Colle,0,0,0,0,0,0,0,0,0,0
606+
10332,Santeramo in Colle,0,0,0,0,0,0,0,0,0,0

recommender_webapp/forms.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class SearchRecommendationDistanceRange(ChoiceEnum):
6363
km60 = 60
6464

6565

66-
# This form is used for searching recommendations
66+
6767
class SearchRecommendationForm(forms.Form):
6868
mood = forms.ChoiceField(
6969
required=True,
@@ -84,7 +84,7 @@ class SearchRecommendationForm(forms.Form):
8484
any_events = forms.BooleanField(initial=False, required=False, label='Any events')
8585

8686

87-
# This form is used for adding a new rating
87+
8888
class AddRatingForm(forms.Form):
8989
mood = forms.ChoiceField(
9090
required=True,
@@ -102,9 +102,7 @@ class SearchPlacesDistanceRange(ChoiceEnum):
102102
__order__ = 'km5 km10'
103103
km5 = 5
104104
km10 = 10
105-
# km30 = 30
106-
# km40 = 40
107-
# km50 = 50
105+
108106

109107

110108
class SearchNearPlacesForm(forms.Form):
@@ -126,7 +124,7 @@ class FullProfileForm(forms.ModelForm):
126124
class Meta:
127125
model = Profile
128126
fields = ('location', 'profession', 'birth_date', 'bio')
129-
# widgets={'birth_date': forms.DateInput(attrs={'class': 'datepicker'})} # Another type of datepicker
127+
130128

131129
location = AutoCompleteField('cities')
132130

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Generated by Django 2.1.5 on 2019-01-26 07:16
2+
3+
from django.conf import settings
4+
from django.db import migrations, models
5+
import django.db.models.deletion
6+
import django.utils.timezone
7+
import recommender_webapp.models
8+
9+
10+
class Migration(migrations.Migration):
11+
12+
initial = True
13+
14+
dependencies = [
15+
('auth', '0009_alter_user_last_name_max_length'),
16+
]
17+
18+
operations = [
19+
migrations.CreateModel(
20+
name='User',
21+
fields=[
22+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
23+
('password', models.CharField(max_length=128, verbose_name='password')),
24+
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
25+
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
26+
('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')),
27+
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
28+
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
29+
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
30+
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
31+
('email', models.EmailField(max_length=254, unique=True, verbose_name='email address')),
32+
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
33+
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
34+
],
35+
options={
36+
'verbose_name': 'user',
37+
'verbose_name_plural': 'users',
38+
'abstract': False,
39+
},
40+
managers=[
41+
('objects', recommender_webapp.models.UserManager()),
42+
],
43+
),
44+
migrations.CreateModel(
45+
name='Comune',
46+
fields=[
47+
('istat', models.CharField(max_length=7, primary_key=True, serialize=False)),
48+
('nome', models.CharField(max_length=100)),
49+
('provincia', models.CharField(max_length=3)),
50+
('regione', models.CharField(max_length=4)),
51+
('prefisso', models.CharField(max_length=6)),
52+
('cap', models.CharField(max_length=6)),
53+
('cod_fis', models.CharField(max_length=6)),
54+
('abitanti', models.IntegerField()),
55+
],
56+
),
57+
migrations.CreateModel(
58+
name='Distanza',
59+
fields=[
60+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
61+
('cittaA', models.CharField(max_length=100)),
62+
('cittaB', models.CharField(max_length=100)),
63+
('distanza', models.FloatField()),
64+
],
65+
),
66+
migrations.CreateModel(
67+
name='Event',
68+
fields=[
69+
('eventId', models.IntegerField(primary_key=True, serialize=False)),
70+
('title', models.TextField()),
71+
('location', models.CharField(blank=True, max_length=40)),
72+
('date_from', models.DateField()),
73+
('date_to', models.DateField()),
74+
('popularity', models.IntegerField()),
75+
('description', models.TextField()),
76+
],
77+
),
78+
migrations.CreateModel(
79+
name='Place',
80+
fields=[
81+
('placeId', models.IntegerField(primary_key=True, serialize=False)),
82+
('name', models.CharField(max_length=100)),
83+
('location', models.CharField(max_length=40)),
84+
('freeEntry', models.BooleanField()),
85+
('bere', models.BooleanField()),
86+
('mangiare', models.BooleanField()),
87+
('benessere', models.BooleanField()),
88+
('dormire', models.BooleanField()),
89+
('goloso', models.BooleanField()),
90+
('libri', models.BooleanField()),
91+
('romantico', models.BooleanField()),
92+
('museo', models.BooleanField()),
93+
('spiaggia', models.BooleanField()),
94+
('teatro', models.BooleanField()),
95+
],
96+
),
97+
migrations.CreateModel(
98+
name='Profile',
99+
fields=[
100+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
101+
('location', models.CharField(max_length=40)),
102+
('birth_date', models.DateField(blank=True, null=True)),
103+
('bio', models.TextField(blank=True, max_length=500)),
104+
('profession', models.CharField(blank=True, max_length=40)),
105+
('empathy', models.FloatField(blank=True, null=True)),
106+
('first_configuration', models.BooleanField(default=False)),
107+
('user', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
108+
],
109+
),
110+
migrations.CreateModel(
111+
name='Rating',
112+
fields=[
113+
('id', models.AutoField(primary_key=True, serialize=False)),
114+
('mood', models.CharField(choices=[('angry', 1), ('joyful', 2), ('sad', 3)], max_length=20)),
115+
('companionship', models.CharField(choices=[('withFriends', 1), ('alone', 2)], max_length=20)),
116+
('rating', models.IntegerField(default=3)),
117+
('place', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='recommender_webapp.Place')),
118+
('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='recommender_webapp.Profile')),
119+
],
120+
),
121+
migrations.CreateModel(
122+
name='SampleRating',
123+
fields=[
124+
('id', models.AutoField(primary_key=True, serialize=False)),
125+
('userId', models.IntegerField()),
126+
('rating', models.IntegerField()),
127+
('placeId', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='recommender_webapp.Place')),
128+
],
129+
),
130+
migrations.AddField(
131+
model_name='event',
132+
name='place',
133+
field=models.ForeignKey(default=0, on_delete=django.db.models.deletion.PROTECT, to='recommender_webapp.Place'),
134+
),
135+
migrations.AlterUniqueTogether(
136+
name='samplerating',
137+
unique_together={('userId', 'placeId')},
138+
),
139+
]

recommender_webapp/migrations/__init__.py

Whitespace-only changes.

recommender_webapp/views.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from recommender_webapp.models import Comune, Distanza, Place, Mood, Companionship, Rating, User, Profile, Event
1212

1313

14+
1415
@csrf_protect
1516
def user_login(request):
1617
"""
@@ -128,13 +129,16 @@ def profile_configuration(request):
128129

129130
if len(user_ratings) >= (constant.RATINGS_PER_CONTEXT_CONF * constant.CONTEXTS):
130131
# Profile configuration finished. We must add user data to LightFM dataset and recreate the model
132+
print("need help 01")
131133
if not request.user.profile.first_configuration:
132134
lightfm_manager.add_user(request.user.id, request.user.profile.location, user_contexts, user_ratings)
133135
request.user.profile.first_configuration = True
134136
request.user.save()
137+
print("need help 02")
135138
return redirect('/')
136139

137140
else:
141+
print("help!!!")
138142
percentage_completion = int(
139143
(len(user_ratings) * 100 / (constant.RATINGS_PER_CONTEXT_CONF * constant.CONTEXTS)))
140144

static/css/font-awesome.min.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/css/selectstyle.css

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/** default and google theme **/
2+
.selectstyle{position:relative;}
3+
.ss_dib{display:inline-block;vertical-align:top;}
4+
.ss_button{margin:0;vertical-align:top;color:#595959;border: 1px solid #cbcbcb;border-radius:3px;width:250px;cursor:pointer;text-decoration:none;background:none;padding:10px;overflow:hidden;clear:both;display:inline-block;vertical-align:top;font-size:12px;font-weight:bold;word-break:break-all;}
5+
.ss_text{white-space:normal;text-overflow:ellipsis;text-indent:0;white-space:nowrap;overflow:hidden;}
6+
.ss_image{position:absolute;width:7px;height:11px;background:url('../images/google.png') no-repeat;}
7+
.ss_ul{list-style:none;padding:8px 0; margin:0; margin-top:-35px;position:absolute;background:#fff;border:1px solid #ccc;-moz-box-shadow:0 1px 5px 1px rgba(0,0,0,0.1);-webkit-box-shadow:0 1px 5px 1px rgba(0,0,0,0.1);box-shadow:0 1px 5px 1px rgba(0,0,0,0.1); border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px; display:none;overflow:auto;z-index:100;}
8+
.ss_ulsearch{margin:0; margin-top:-35px;position:absolute;background:#fff;border:1px solid #ccc;-moz-box-shadow:0 1px 5px 1px rgba(0,0,0,0.1);-webkit-box-shadow:0 1px 5px 1px rgba(0,0,0,0.1);box-shadow:0 1px 5px 1px rgba(0,0,0,0.1); border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;overflow:auto;z-index:100;display:none;}
9+
.ss_ulsearch .ss_ul{display:block;position:relative;margin-top:0;border:none;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none; border-radius:0px;-moz-border-radius:0px;-webkit-border-radius:0px;}
10+
.ss_ulsearch .search{border-bottom:1px solid #ccc;padding:0;}
11+
.ss_ulsearch .search input{background:inherit;border:none;height:100%;padding:10px 15px;outline:none;font-size:14px;width:calc(100% - 30px);width:-webkit-calc(100% - 30px);width:-moz-calc(100% - 30px);width:-o-calc(100% - 30px);background:url('../images/ful_grid_img.png') no-repeat;background-position: top 8px right 6px;}
12+
.ss_ulsearch .search input:focus{outline:none;}
13+
.ss_ulsearch .nosearch{text-align:center;font-size:12px;padding-bottom:10px;background:#fff;}
14+
.ss_ul li{padding:10px 15px;cursor:pointer;border:none;text-align:left;color:#595959;transition-duration:.3s;-moz-transition-duration:.3s;-webkit-transition-duration:.3s;-o-transition-duration:.3s;font-size:14px;}
15+
.ss_ul li:hover{border:none;background:#eee;}
16+
.ss_ul li .ssli_text{vertical-align:top;display:inline-block;}
17+
.ss_ul li .ssli_image{display:inline-block;width:16px;height:16px;margin-right:10px;margin-top:-1px;vertical-align:top;}
18+
.ss_ul li .ssli_image img{width:16px;height:16px;}
19+
.ss_ul::-webkit-scrollbar {width:10px;}
20+
.ss_ul::-webkit-scrollbar:horizontal{height:10px;}
21+
.ss_ul::-webkit-scrollbar-track {border-left:1px solid #D3D3D3;background:#F5F5F5;}
22+
.ss_ul::-webkit-scrollbar-thumb {background:#C4C4C4;}
23+
24+
25+
/** Dark theme **/
26+
.selectstyle.dark{position:relative;}
27+
.selectstyle.dark .ss_button{color:#eee;border: 1px solid #ccc;background:#5B5B5B;}
28+
.selectstyle.dark .ss_image{width:16px;height:16px;background:url('../images/br_down.png') no-repeat;margin-left:-8px;margin-top:-2px;}
29+
.selectstyle.dark .ss_ul{background:#777;border-color:#333;-moz-box-shadow:0 1px 5px 1px rgba(255,255,255,0.15);-webkit-box-shadow:0 1px 5px 1px rgba(255,255,255,0.15);box-shadow:0 1px 5px 1px rgba(255,255,255,0.15);}
30+
.selectstyle.dark .ss_ulsearch .ss_ul{display:block;position:relative;margin-top:0;border:none;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none; border-radius:0px;-moz-border-radius:0px;-webkit-border-radius:0px;}
31+
.selectstyle.dark .ss_ulsearch{background:#5B5B5B;border-color:#333;-moz-box-shadow:0 1px 5px 1px rgba(255,255,255,0.15);-webkit-box-shadow:0 1px 5px 1px rgba(255,255,255,0.15);box-shadow:0 1px 5px 1px rgba(255,255,255,0.15);}
32+
.selectstyle.dark .ss_ulsearch .search{border-bottom-color:#333;}
33+
.selectstyle.dark .ss_ulsearch .search input{background:url('../images/search.png') no-repeat;background-position: top 8px right 6px;background-size:24px 24px;color:#eee;}
34+
.selectstyle.dark .ss_ulsearch .nosearch{background:#777;}
35+
.selectstyle.dark .ss_ul li{color:#ddd;}
36+
.selectstyle.dark .ss_ul li:hover{border:none;background:#444;color:#eee;}
37+
.selectstyle.dark .ss_ul::-webkit-scrollbar-track {border-left:1px solid #333;background:#888;}
38+
.selectstyle.dark .ss_ul::-webkit-scrollbar-thumb {background:#5B5B5B;}

0 commit comments

Comments
 (0)