Commit 8a8e8cf6 authored by Florent Chehab's avatar Florent Chehab
Browse files

Merge branch 'frontend' into 'master'

New Frontend initialize

Closes #11

See merge request chehabfl/outgoing_rex!15
parents f7b3fc08 a157cc69
from django.utils import timezone
import reversion
class LoadGeneric(object):
@classmethod
def add_info(cls, obj, admin):
with reversion.create_revision():
obj.moderated_by = admin
obj.updated_by = admin
obj.moderated_on = timezone.now()
obj.updated_on = timezone.now()
obj.save()
from backend.models.location import City, Country
from backend.models.university import University, Campus
import os
import pandas as pd
from .loadGeneric import LoadGeneric
class LoadUniversities(LoadGeneric):
def __init__(self, admin):
self.admin = admin
def load(self):
tmp = os.path.join(os.path.realpath(__file__),
'../../assets/destinations_extracted.csv')
destinations_path = os.path.abspath(tmp)
data = pd.read_csv(destinations_path, sep=',', header=0,
dtype=object)
for index, row in data.iterrows():
univ_name, city_name, country_code, lat, lon = row
lat = round(float(lat), 6)
lon = round(float(lon), 6)
country = Country.objects.filter(pk=country_code)[0]
city = City(
name=city_name,
country=country
)
city.save()
self.add_info(city, self.admin)
univ = University(
name=univ_name
)
univ.save()
self.add_info(univ, self.admin)
main_campus = Campus(
is_main_campus=True,
name="Campus - " + univ.name,
city=city,
university=univ,
lat=lat,
lon=lon
)
main_campus.save()
self.add_info(main_campus, self.admin)
# Generated by Django 2.0.3 on 2018-08-24 07:10
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('backend', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='campus',
name='university',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='univ_campus', to='backend.University'),
),
]
# Generated by Django 2.0.3 on 2018-08-24 08:11
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),
('backend', '0002_auto_20180824_0910'),
]
operations = [
migrations.AddField(
model_name='campus',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='campus',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='campusaccommodation',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='campusaccommodation',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='campuscultureandstudentlife',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='campuscultureandstudentlife',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='campusotherstuff',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='campusotherstuff',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='campustransport',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='campustransport',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='cityotherstuff',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='cityotherstuff',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='cityphoto',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='cityphoto',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='citytourism',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='citytourism',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='citytransport',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='citytransport',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='countryculture',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='countryculture',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='countrydri',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='countrydri',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='countryhealthinsurance',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='countryhealthinsurance',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='countryotherinsurance',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='countryotherinsurance',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='countryotherstuff',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='countryotherstuff',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='countryphoto',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='countryphoto',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='countryscholarship',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='countryscholarship',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='countrytourism',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='countrytourism',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='countrytransport',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='countrytransport',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='countryvisaadministrative',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='countryvisaadministrative',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='university',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='university',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='universitycourses',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='universitycourses',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='universityculture',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='universityculture',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='universitydri',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='universitydri',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='universityinfo',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='universityinfo',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='universityinsurance',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='universityinsurance',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='universityotherstuff',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='universityotherstuff',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='universityphoto',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='universityphoto',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='universityscholarship',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='universityscholarship',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='universitysemestersdates',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='universitysemestersdates',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='universityspecialoffer',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='universityspecialoffer',
name='updated_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
]
# Generated by Django 2.0.3 on 2018-08-24 13:51
from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('contenttypes', '0002_remove_content_type_name'),
('backend', '0003_auto_20180824_1011'),
]
operations = [
migrations.CreateModel(
name='PendingModeration',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('object_id', models.CharField(max_length=100)),
('content_object', django.contrib.postgres.fields.jsonb.JSONField()),
('delete', models.NullBooleanField(default=None)),
('approve', models.NullBooleanField(default=None)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
],
),
]
# Generated by Django 2.0.3 on 2018-08-24 13:53
import django.contrib.postgres.fields.jsonb
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('backend', '0004_pendingmoderation'),
]
operations = [
migrations.AlterField(
model_name='pendingmoderation',
name='content_object',
field=django.contrib.postgres.fields.jsonb.JSONField(default={}),
),
]
# Generated by Django 2.0.3 on 2018-08-24 13:58
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('backend', '0005_auto_20180824_1553'),
]
operations = [
migrations.RenameField(
model_name='pendingmoderation',
old_name='content_object',
new_name='new_object',
),
]
# Generated by Django 2.0.3 on 2018-08-24 15:41
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('backend', '0006_auto_20180824_1558'),
]
operations = [
migrations.RenameField(
model_name='pendingmoderation',
old_name='new_object',
new_name='object_to_moderate',
),
]
# Generated by Django 2.0.3 on 2018-08-24 19:28
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),
('backend', '0007_auto_20180824_1741'),
]
operations = [
migrations.RenameField(
model_name='pendingmoderation',
old_name='object_to_moderate',
new_name='new_object',
),
migrations.RemoveField(
model_name='pendingmoderation',
name='approve',
),
migrations.RemoveField(
model_name='pendingmoderation',
name='delete',
),
migrations.RemoveField(
model_name='university',
name='updated_at',
),
migrations.AddField(
model_name='university',
name='moderated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='moderated', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='university',
name='moderated_on',
field=models.DateTimeField(null=True),
),
migrations.AddField(
model_name='university',
name='updated_on',
field=models.DateTimeField(null=True),
),
migrations.AlterField(
model_name='campus',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='campusaccommodation',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='campuscultureandstudentlife',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='campusotherstuff',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='campustransport',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(