21# created invite model
This commit is contained in:
parent
c25bebed43
commit
c9465b91a3
@ -1,7 +1,7 @@
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.admin import UserAdmin
|
||||
|
||||
from .models import Account, Profile
|
||||
from .models import Account, Profile, Invite
|
||||
|
||||
|
||||
class MyAdminAccounts(UserAdmin):
|
||||
@ -28,3 +28,4 @@ class MyAdminAccounts(UserAdmin):
|
||||
|
||||
admin.site.register(Account, MyAdminAccounts)
|
||||
admin.site.register(Profile)
|
||||
admin.site.register(Invite)
|
||||
|
28
users/migrations/0004_invite.py
Normal file
28
users/migrations/0004_invite.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Generated by Django 3.1.4 on 2021-01-15 11:00
|
||||
|
||||
import ckeditor.fields
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jobs', '0009_auto_20210114_1950'),
|
||||
('users', '0003_auto_20210114_1950'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Invite',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('date', models.DateField(blank=True, default=None, null=True)),
|
||||
('message', ckeditor.fields.RichTextField(blank=True)),
|
||||
('unread', models.BooleanField(default=True)),
|
||||
('job', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invites', to='jobs.job')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invites', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
@ -7,6 +7,8 @@ from django.utils.translation import gettext_lazy as _
|
||||
from PIL import Image
|
||||
from ckeditor.fields import RichTextField
|
||||
|
||||
from jobs.models import Job
|
||||
|
||||
|
||||
class UserManager(BaseUserManager):
|
||||
use_in_migrations = True
|
||||
@ -74,6 +76,14 @@ class Profile(models.Model):
|
||||
img.save(self.image.path)
|
||||
|
||||
|
||||
class Invite(models.Model):
|
||||
user = models.ForeignKey(Account, on_delete=models.CASCADE, related_name="invites")
|
||||
job = models.ForeignKey(Job, on_delete=models.CASCADE, related_name="invites")
|
||||
date = models.DateField(default=None, blank=True, null=True)
|
||||
message = RichTextField(blank=True)
|
||||
unread = models.BooleanField(default=True)
|
||||
|
||||
|
||||
@receiver(models.signals.post_save, sender=Account)
|
||||
def post_save_user_signal(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
|
Loading…
Reference in New Issue
Block a user