always use get_model in migrations
This commit is contained in:
parent
7d1786f143
commit
a59509a432
5 changed files with 3 additions and 22 deletions
|
@ -1,8 +1,6 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
|
||||||
from authentication.models import ExtendedUser
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
@ -11,6 +9,7 @@ class Migration(migrations.Migration):
|
||||||
]
|
]
|
||||||
|
|
||||||
def create_legacy_user(apps, schema_editor):
|
def create_legacy_user(apps, schema_editor):
|
||||||
|
ExtendedUser = apps.get_model('authentication', 'ExtendedUser')
|
||||||
ExtendedUser.objects.create_user(settings.LEGACY_USER_NAME, 'mail@' + settings.MAIL_DOMAIN,
|
ExtendedUser.objects.create_user(settings.LEGACY_USER_NAME, 'mail@' + settings.MAIL_DOMAIN,
|
||||||
settings.LEGACY_USER_PASSWORD)
|
settings.LEGACY_USER_PASSWORD)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
import files.models
|
import files.models
|
||||||
from mail.models import Email
|
|
||||||
from mail.protocol import parse_email_body
|
from mail.protocol import parse_email_body
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,6 +23,7 @@ class Migration(migrations.Migration):
|
||||||
]
|
]
|
||||||
|
|
||||||
def generate_email_attachments(apps, schema_editor):
|
def generate_email_attachments(apps, schema_editor):
|
||||||
|
Email = apps.get_model('mail', 'Email')
|
||||||
for email in Email.objects.all():
|
for email in Email.objects.all():
|
||||||
raw = email.raw
|
raw = email.raw
|
||||||
if raw is None or raw == '':
|
if raw is None or raw == '':
|
||||||
|
|
|
@ -22,11 +22,6 @@ class IssueViewSet(viewsets.ModelViewSet):
|
||||||
queryset = IssueThread.objects.all()
|
queryset = IssueThread.objects.all()
|
||||||
|
|
||||||
|
|
||||||
class CommentViewSet(viewsets.ModelViewSet):
|
|
||||||
serializer_class = CommentSerializer
|
|
||||||
queryset = Comment.objects.all()
|
|
||||||
|
|
||||||
|
|
||||||
@api_view(['POST'])
|
@api_view(['POST'])
|
||||||
@permission_classes([IsAuthenticated])
|
@permission_classes([IsAuthenticated])
|
||||||
@permission_required('tickets.add_issuethread', raise_exception=True)
|
@permission_required('tickets.add_issuethread', raise_exception=True)
|
||||||
|
@ -118,7 +113,6 @@ def add_comment(request, pk):
|
||||||
|
|
||||||
router = routers.SimpleRouter()
|
router = routers.SimpleRouter()
|
||||||
router.register(r'tickets', IssueViewSet, basename='issues')
|
router.register(r'tickets', IssueViewSet, basename='issues')
|
||||||
router.register(r'comments', CommentViewSet, basename='comments')
|
|
||||||
|
|
||||||
urlpatterns = ([
|
urlpatterns = ([
|
||||||
re_path(r'^tickets/(?P<pk>\d+)/reply/$', reply, name='reply'),
|
re_path(r'^tickets/(?P<pk>\d+)/reply/$', reply, name='reply'),
|
||||||
|
|
|
@ -2,17 +2,15 @@
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
from tickets.models import IssueThread
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('tickets', '0005_remove_issuethread_last_activity'),
|
('tickets', '0005_remove_issuethread_last_activity'),
|
||||||
]
|
]
|
||||||
|
|
||||||
def set_uuid(apps, schema_editor):
|
def set_uuid(apps, schema_editor):
|
||||||
import uuid
|
import uuid
|
||||||
|
IssueThread = apps.get_model('tickets', 'IssueThread')
|
||||||
for issue_thread in IssueThread.objects.all():
|
for issue_thread in IssueThread.objects.all():
|
||||||
issue_thread.uuid = str(uuid.uuid4())
|
issue_thread.uuid = str(uuid.uuid4())
|
||||||
issue_thread.save()
|
issue_thread.save()
|
||||||
|
|
|
@ -247,16 +247,6 @@ class IssueApiTest(TestCase):
|
||||||
self.assertEqual(timeline[1]['subject'], 'test issue')
|
self.assertEqual(timeline[1]['subject'], 'test issue')
|
||||||
self.assertEqual(timeline[1]['body'], 'test')
|
self.assertEqual(timeline[1]['body'], 'test')
|
||||||
|
|
||||||
def test_post_comment(self):
|
|
||||||
issue = IssueThread.objects.create(
|
|
||||||
name="test issue",
|
|
||||||
)
|
|
||||||
response = self.client.post('/api/2/comments/', {'comment': 'test', 'issue_thread': issue.id})
|
|
||||||
self.assertEqual(response.status_code, 201)
|
|
||||||
self.assertEqual(response.json()['comment'], 'test')
|
|
||||||
self.assertEqual(response.json()['issue_thread'], issue.id)
|
|
||||||
self.assertEqual(response.json()['timestamp'], response.json()['timestamp'])
|
|
||||||
|
|
||||||
def test_post_comment_altenative(self):
|
def test_post_comment_altenative(self):
|
||||||
issue = IssueThread.objects.create(
|
issue = IssueThread.objects.create(
|
||||||
name="test issue",
|
name="test issue",
|
||||||
|
|
Loading…
Reference in a new issue