Skip to content
This repository has been archived by the owner on May 7, 2019. It is now read-only.

Commit

Permalink
Added author field to Post and Thread
Browse files Browse the repository at this point in the history
  • Loading branch information
nylar committed May 20, 2015
1 parent 32e205c commit 1f1dc42
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
22 changes: 22 additions & 0 deletions posts/migrations/0003_post_author.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('posts', '0002_post_depth'),
]

operations = [
migrations.AddField(
model_name='post',
name='author',
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.SET_NULL, blank=True, to=settings.AUTH_USER_MODEL),
),
]
2 changes: 2 additions & 0 deletions posts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Post(models.Model):
# Foreign Keys
thread = models.ForeignKey('threads.Thread')
parent = models.OneToOneField('self', null=True, blank=True)
author = models.OneToOneField(
'users.User', blank=True, null=True, on_delete=models.SET_NULL)

def __str__(self):
return self.slug
Expand Down
22 changes: 22 additions & 0 deletions threads/migrations/0002_thread_author.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('threads', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='thread',
name='author',
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.SET_NULL, blank=True, to=settings.AUTH_USER_MODEL),
),
]
2 changes: 2 additions & 0 deletions threads/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Thread(models.Model):

# Relations
forum = models.ForeignKey('forums.Forum')
author = models.OneToOneField(
'users.User', blank=True, null=True, on_delete=models.SET_NULL)

# Managers
objects = models.Manager()
Expand Down

0 comments on commit 1f1dc42

Please sign in to comment.