models/drafts: Add a model for storing Draft messages.

Also add a Draft object-to-dictionary conversion method.
The following commits will provide an API around this
model using which our clients can sync drafts across each
other (if they so wish too). As of making this commit, we
haven't finalized exactly how our clients will use this.

See https://chat.zulip.org/#narrow/stream/2-general/topic/drafts
For some of the discussion around this model and in general,
around this feature.

Signed-off-by: Hemanth V. Alluri <hdrive1999@gmail.com>
This commit is contained in:
Hemanth V. Alluri
2020-07-23 22:54:22 +05:30
committed by Tim Abbott
parent d5f42e2722
commit 0e893b9045
3 changed files with 69 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
# Generated by Django 2.2.14 on 2020-07-23 17:07
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('zerver', '0296_remove_userprofile_short_name'),
]
operations = [
migrations.CreateModel(
name='Draft',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('topic', models.CharField(db_index=True, max_length=60)),
('content', models.TextField()),
('last_edit_time', models.DateTimeField(db_index=True)),
('recipient', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='zerver.Recipient')),
('user_profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]