mirror of
https://github.com/QingdaoU/Spirit.git
synced 2025-01-16 17:26:07 +00:00
comment app
This commit is contained in:
parent
76664cea68
commit
a6dc23185e
@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
default_app_config = 'spirit.comment.apps.SpiritCommentConfig'
|
12
spirit/comment/apps.py
Normal file
12
spirit/comment/apps.py
Normal file
@ -0,0 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class SpiritCommentConfig(AppConfig):
|
||||
|
||||
name = 'spirit.comment'
|
||||
verbose_name = "Spirit Comment"
|
||||
label = 'spirit_comment'
|
@ -23,6 +23,7 @@ class CommentBookmark(models.Model):
|
||||
verbose_name = _("comment bookmark")
|
||||
verbose_name_plural = _("comments bookmarks")
|
||||
db_table = 'spirit_bookmark_commentbookmark' # TODO: remove in Spirit 0.4
|
||||
app_label = 'spirit'
|
||||
|
||||
def get_absolute_url(self):
|
||||
return paginator.get_url(
|
||||
|
@ -17,7 +17,7 @@ REASON_CHOICES = (
|
||||
class CommentFlag(models.Model):
|
||||
|
||||
moderator = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True)
|
||||
comment = models.OneToOneField('spirit.Comment')
|
||||
comment = models.OneToOneField('spirit_comment.Comment')
|
||||
|
||||
date = models.DateTimeField(default=timezone.now)
|
||||
is_closed = models.BooleanField(default=False)
|
||||
@ -27,6 +27,7 @@ class CommentFlag(models.Model):
|
||||
verbose_name = _("comment flag")
|
||||
verbose_name_plural = _("comments flags")
|
||||
db_table = 'spirit_flag_commentflag' # TODO: remove in Spirit 0.4
|
||||
app_label = 'spirit'
|
||||
|
||||
# def get_absolute_url(self):
|
||||
# pass
|
||||
@ -35,7 +36,7 @@ class CommentFlag(models.Model):
|
||||
class Flag(models.Model):
|
||||
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL)
|
||||
comment = models.ForeignKey('spirit.Comment')
|
||||
comment = models.ForeignKey('spirit_comment.Comment')
|
||||
|
||||
date = models.DateTimeField(default=timezone.now)
|
||||
reason = models.IntegerField(_("reason"), choices=REASON_CHOICES)
|
||||
@ -47,3 +48,4 @@ class Flag(models.Model):
|
||||
verbose_name = _("flag")
|
||||
verbose_name_plural = _("flags")
|
||||
db_table = 'spirit_flag_flag' # TODO: remove in Spirit 0.4
|
||||
app_label = 'spirit'
|
||||
|
@ -11,7 +11,7 @@ from django.db import transaction
|
||||
|
||||
class CommentHistory(models.Model):
|
||||
|
||||
comment_fk = models.ForeignKey('spirit.Comment', verbose_name=_("original comment"))
|
||||
comment_fk = models.ForeignKey('spirit_comment.Comment', verbose_name=_("original comment"))
|
||||
|
||||
comment_html = models.TextField(_("comment html"))
|
||||
date = models.DateTimeField(default=timezone.now)
|
||||
@ -21,6 +21,7 @@ class CommentHistory(models.Model):
|
||||
verbose_name = _("comment history")
|
||||
verbose_name_plural = _("comments history")
|
||||
db_table = 'spirit_history_commenthistory' # TODO: remove in Spirit 0.4
|
||||
app_label = 'spirit'
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('spirit:comment:history:detail', kwargs={'pk': str(self.id), })
|
||||
|
@ -12,7 +12,7 @@ from django.utils import timezone
|
||||
class CommentLike(models.Model):
|
||||
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL)
|
||||
comment = models.ForeignKey('spirit.Comment', related_name='comment_likes')
|
||||
comment = models.ForeignKey('spirit_comment.Comment', related_name='comment_likes')
|
||||
|
||||
date = models.DateTimeField(default=timezone.now)
|
||||
|
||||
@ -22,6 +22,7 @@ class CommentLike(models.Model):
|
||||
verbose_name = _("like")
|
||||
verbose_name_plural = _("likes")
|
||||
db_table = 'spirit_like_commentlike' # TODO: remove in Spirit 0.4
|
||||
app_label = 'spirit'
|
||||
|
||||
def get_delete_url(self):
|
||||
return reverse('spirit:comment:like:delete', kwargs={'pk': str(self.pk), })
|
||||
|
46
spirit/comment/migrations/0001_initial.py
Normal file
46
spirit/comment/migrations/0001_initial.py
Normal file
@ -0,0 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
import django.utils.timezone
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('spirit_topic', '0002_auto_20150724_2106'),
|
||||
('spirit', '0020_auto_20150724_2209')
|
||||
]
|
||||
|
||||
state_operations = [
|
||||
migrations.CreateModel(
|
||||
name='Comment',
|
||||
fields=[
|
||||
('id', models.AutoField(serialize=False, auto_created=True, primary_key=True, verbose_name='ID')),
|
||||
('comment', models.TextField(max_length=3000, verbose_name='comment')),
|
||||
('comment_html', models.TextField(verbose_name='comment html')),
|
||||
('action', models.IntegerField(default=0, choices=[(0, 'comment'), (1, 'topic moved'), (2, 'topic closed'), (3, 'topic unclosed'), (4, 'topic pinned'), (5, 'topic unpinned')], verbose_name='action')),
|
||||
('date', models.DateTimeField(default=django.utils.timezone.now)),
|
||||
('is_removed', models.BooleanField(default=False)),
|
||||
('is_modified', models.BooleanField(default=False)),
|
||||
('ip_address', models.GenericIPAddressField(blank=True, null=True)),
|
||||
('modified_count', models.PositiveIntegerField(default=0, verbose_name='modified count')),
|
||||
('likes_count', models.PositiveIntegerField(default=0, verbose_name='likes count')),
|
||||
('topic', models.ForeignKey(to='spirit_topic.Topic')),
|
||||
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, verbose_name='user')),
|
||||
],
|
||||
options={
|
||||
'db_table': 'spirit_comment_comment',
|
||||
'verbose_name_plural': 'comments',
|
||||
'ordering': ['-date', '-pk'],
|
||||
'verbose_name': 'comment',
|
||||
},
|
||||
),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.SeparateDatabaseAndState(
|
||||
state_operations=state_operations)
|
||||
]
|
18
spirit/comment/migrations/0002_auto_20150724_2212.py
Normal file
18
spirit/comment/migrations/0002_auto_20150724_2212.py
Normal file
@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('spirit_comment', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelTable(
|
||||
name='comment',
|
||||
table=None,
|
||||
),
|
||||
]
|
0
spirit/comment/migrations/__init__.py
Normal file
0
spirit/comment/migrations/__init__.py
Normal file
@ -48,7 +48,6 @@ class Comment(models.Model):
|
||||
ordering = ['-date', '-pk']
|
||||
verbose_name = _("comment")
|
||||
verbose_name_plural = _("comments")
|
||||
db_table = 'spirit_comment_comment' # TODO: remove in Spirit 0.4
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('spirit:comment:find', kwargs={'pk': str(self.id), })
|
||||
|
55
spirit/migrations/0020_auto_20150724_2209.py
Normal file
55
spirit/migrations/0020_auto_20150724_2209.py
Normal file
@ -0,0 +1,55 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('spirit', '0019_auto_20150724_2155'),
|
||||
]
|
||||
|
||||
state_operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='comment',
|
||||
name='topic',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='comment',
|
||||
name='user',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='commentflag',
|
||||
name='comment',
|
||||
field=models.OneToOneField(to='spirit_comment.Comment'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='commenthistory',
|
||||
name='comment_fk',
|
||||
field=models.ForeignKey(verbose_name='original comment', to='spirit_comment.Comment'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='commentlike',
|
||||
name='comment',
|
||||
field=models.ForeignKey(related_name='comment_likes', to='spirit_comment.Comment'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='flag',
|
||||
name='comment',
|
||||
field=models.ForeignKey(to='spirit_comment.Comment'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='topicnotification',
|
||||
name='comment',
|
||||
field=models.ForeignKey(to='spirit_comment.Comment', blank=True, null=True),
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='Comment',
|
||||
),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.SeparateDatabaseAndState(
|
||||
state_operations=state_operations)
|
||||
]
|
22
spirit/migrations/0021_auto_20150724_2210.py
Normal file
22
spirit/migrations/0021_auto_20150724_2210.py
Normal file
@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
def rename_model_content_type(apps, schema_editor):
|
||||
content_types = apps.get_model('contenttypes.ContentType')
|
||||
content_types.objects.filter(
|
||||
app_label='spirit', model='Comment'.lower()
|
||||
).update(app_label='spirit_comment')
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('spirit', '0020_auto_20150724_2209'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(rename_model_content_type),
|
||||
]
|
@ -1,7 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# TODO: remove in Spirit 0.4
|
||||
from .comment.models import Comment
|
||||
from .comment.history.models import CommentHistory
|
||||
from .comment.bookmark.models import CommentBookmark
|
||||
from .comment.flag.models import Flag
|
||||
@ -14,7 +13,7 @@ from .user.models import User
|
||||
|
||||
|
||||
__all__ = [
|
||||
'Comment', 'CommentHistory', 'CommentBookmark', 'Flag',
|
||||
'CommentLike', 'Topic', 'TopicUnread', 'TopicFavorite', 'TopicNotification',
|
||||
'CommentHistory', 'CommentBookmark', 'Flag',
|
||||
'CommentLike', 'TopicUnread', 'TopicFavorite', 'TopicNotification',
|
||||
'TopicPoll', 'TopicPollChoice', 'TopicPrivate', 'User'
|
||||
]
|
||||
|
@ -51,6 +51,7 @@ INSTALLED_APPS = [
|
||||
'spirit.user',
|
||||
'spirit.topic',
|
||||
'spirit.topic.favorite',
|
||||
'spirit.comment',
|
||||
# 'spirit.core.tests'
|
||||
]
|
||||
|
||||
|
@ -24,7 +24,7 @@ class TopicNotification(models.Model):
|
||||
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_("user"))
|
||||
topic = models.ForeignKey('spirit_topic.Topic')
|
||||
comment = models.ForeignKey('spirit.Comment', null=True, blank=True)
|
||||
comment = models.ForeignKey('spirit_comment.Comment', null=True, blank=True)
|
||||
|
||||
date = models.DateTimeField(default=timezone.now)
|
||||
action = models.IntegerField(choices=ACTION_CHOICES, default=UNDEFINED)
|
||||
|
Loading…
x
Reference in New Issue
Block a user