Commit a2264cb6 authored by Florent Chehab's avatar Florent Chehab

University model playground working

parent 0b9ee38f
......@@ -4,3 +4,4 @@ myvenv
db.sqlite3
/static
.DS_Store
/media
\ No newline at end of file
......@@ -7,5 +7,6 @@
"**/CVS": true,
"**/.DS_Store": true,
"**/__pycache__":true
}
},
"cSpell.language": "en"
}
\ No newline at end of file
......@@ -140,4 +140,7 @@ USE_TZ = True
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
\ No newline at end of file
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
from django.conf import settings
from django.conf.urls.static import static
from django.conf.urls import include, url
from django.contrib import admin
import django_cas_ng.views
......@@ -10,4 +12,7 @@ urlpatterns = [
url(r'^accounts/logout$', django_cas_ng.views.logout, name='cas_ng_logout'),
url(r'^accounts/callback$', django_cas_ng.views.callback, name='cas_ng_proxy_callback'),
url(r'', include('rex.urls')),
]
\ No newline at end of file
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
......@@ -2,3 +2,5 @@ OutGoing_REX
Django==2.0.3
django-cas-ng>=3.5.9
django-markdownx==2.0.22
Pillow==5.0.0
django-imagekit==4.0.2
from django.contrib import admin
from .models import Post
admin.site.register(Post)
from .models.university import University
admin.site.register(University)
# Generated by Django 2.0.3 on 2018-04-01 09:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rex', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='University',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('localization_lat', models.DecimalField(decimal_places=6, max_digits=10)),
('localization_lon', models.DecimalField(decimal_places=6, max_digits=10)),
],
),
migrations.RemoveField(
model_name='post',
name='author',
),
migrations.DeleteModel(
name='Post',
),
]
# Generated by Django 2.0.3 on 2018-04-01 10:09
from django.db import migrations, models
import django.utils.timezone
import uuid
class Migration(migrations.Migration):
dependencies = [
('rex', '0002_auto_20180401_1154'),
]
operations = [
migrations.AddField(
model_name='university',
name='logo',
field=models.ImageField(default=django.utils.timezone.now, upload_to='uploads/<django.db.models.fields.UUIDField>'),
preserve_default=False,
),
migrations.AlterField(
model_name='university',
name='id',
field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False),
),
]
from django.db import models
from django.utils import timezone
class Post(models.Model):
author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
title = models.CharField(max_length=200)
text = models.TextField()
created_date = models.DateTimeField(
default=timezone.now)
published_date = models.DateTimeField(
blank=True, null=True)
def publish(self):
self.published_date = timezone.now()
self.save()
def __str__(self):
return self.title
\ No newline at end of file
from .country import Country
\ No newline at end of file
from django.db import models
class Country(models.Model):
author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
name = models.CharField(max_length=200)
\ No newline at end of file
from .university import University
\ No newline at end of file
from django.db import models
import uuid
class University(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=200)
localization_lat = models.DecimalField(max_digits=10, decimal_places=6)
localization_lon = models.DecimalField(max_digits=10, decimal_places=6)
logo = models.ImageField(upload_to='uploads/'+str(id))
def localization(self):
return {'lat':self.localization_lat, 'lon':self.localization_lon}
\ No newline at end of file
......@@ -2,5 +2,5 @@ from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.post_list, name='post_list'),
url(r'^$', views.home, name='home'),
]
\ No newline at end of file
from django.shortcuts import render
from django.utils import timezone
from .models import Post
from .models.university import University
def post_list(request):
posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date')
return render(request, 'rex/post_list.html', {'posts': posts})
\ No newline at end of file
def home(request):
pass
# from .models import Post
# def post_list(request):
# posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date')
# return render(request, 'rex/post_list.html', {'posts': posts})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment