Skip to content

Commit

Permalink
Fix #657 - Create homepage model (#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
gideonthomas authored and gvn committed Sep 18, 2017
1 parent feade20 commit 5342d5c
Show file tree
Hide file tree
Showing 15 changed files with 137 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-08-31 17:31
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('homepage', '0001_initial'),
('highlights', '0003_remove_highlight_featured'),
]

operations = [
migrations.AddField(
model_name='highlight',
name='homepage',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='highlights', to='homepage.Homepage'),
),
]
8 changes: 8 additions & 0 deletions network-api/app/networkapi/highlights/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from adminsortable.models import SortableMixin
from mezzanine.core.fields import RichTextField
from networkapi.utility.images import get_image_upload_path
from networkapi.homepage.models import Homepage


def get_highlights_image_upload_path(instance, filename):
Expand Down Expand Up @@ -78,6 +79,13 @@ class Highlight(SortableMixin):
editable=False,
db_index=True,
)
homepage = models.ForeignKey(
Homepage,
related_name='highlights',
null=True,
blank=True,
on_delete=models.SET_NULL
)

objects = HighlightQuerySet.as_manager()

Expand Down
Empty file.
3 changes: 3 additions & 0 deletions network-api/app/networkapi/homepage/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions network-api/app/networkapi/homepage/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class HomepageConfig(AppConfig):
name = 'homepage'
22 changes: 22 additions & 0 deletions network-api/app/networkapi/homepage/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-08-31 17:31
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Homepage',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
],
),
]
Empty file.
10 changes: 10 additions & 0 deletions network-api/app/networkapi/homepage/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.db import models


# Create your models here.
class Homepage(models.Model):
# All the fields are created as Foreign Keys in the related models so
# that we have a 1:Many relationship between the homepage and related model
# i.e., one (the only) Homepage model has many instances of the related
# model(s).
pass
3 changes: 3 additions & 0 deletions network-api/app/networkapi/homepage/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase # noqa: F401

# Create your tests here.
3 changes: 3 additions & 0 deletions network-api/app/networkapi/homepage/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# from django.shortcuts import render

# Create your views here.
22 changes: 22 additions & 0 deletions network-api/app/networkapi/news/migrations/0009_news_homepage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-08-31 17:31
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('homepage', '0001_initial'),
('news', '0008_auto_20170723_0853'),
]

operations = [
migrations.AddField(
model_name='news',
name='homepage',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='news', to='homepage.Homepage'),
),
]
8 changes: 8 additions & 0 deletions network-api/app/networkapi/news/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from networkapi.utility.images import get_image_upload_path
from filebrowser_safe.fields import FileBrowseField
from networkapi.homepage.models import Homepage


def get_news_glyph_upload_path(instance, filename):
Expand Down Expand Up @@ -105,6 +106,13 @@ class News(models.Model):
null=True,
blank=True,
)
homepage = models.ForeignKey(
Homepage,
related_name='news',
null=True,
blank=True,
on_delete=models.SET_NULL
)

objects = NewsQuerySet.as_manager()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-08-31 17:31
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('homepage', '0001_initial'),
('people', '0023_auto_20170504_2327'),
]

operations = [
migrations.AddField(
model_name='person',
name='homepage',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='leaders', to='homepage.Homepage'),
),
]
8 changes: 8 additions & 0 deletions network-api/app/networkapi/people/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from adminsortable.models import SortableMixin

from networkapi.utility.images import get_image_upload_path
from networkapi.homepage.models import Homepage


def get_people_image_upload_path(instance, filename):
Expand Down Expand Up @@ -132,6 +133,13 @@ class Person(SortableMixin):
editable=False,
db_index=True,
)
homepage = models.ForeignKey(
Homepage,
related_name='leaders',
null=True,
blank=True,
on_delete=models.SET_NULL
)

objects = PeopleQuerySet.as_manager()

Expand Down
1 change: 1 addition & 0 deletions network-api/app/networkapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
'adminsortable',

# the network site
'networkapi.homepage',
'networkapi.people',
'networkapi.news',
'networkapi.utility',
Expand Down

0 comments on commit 5342d5c

Please sign in to comment.