Add migration for Category and Topic, apply to Team and Event models

This commit is contained in:
Michael Hall 2018-02-25 17:03:10 -05:00
parent ba094c8130
commit 7a577250b3
3 changed files with 68 additions and 1 deletions

View file

@ -0,0 +1,62 @@
# Generated by Django 2.0 on 2018-02-25 22:02
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('events', '0008_add-team-description'),
]
operations = [
migrations.CreateModel(
name='Category',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=256)),
('description', models.TextField()),
('img', models.URLField()),
],
),
migrations.CreateModel(
name='Topic',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=256)),
('description', models.TextField()),
('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='events.Category')),
],
),
migrations.AlterField(
model_name='event',
name='tags',
field=models.CharField(blank=True, help_text='Comma-separates list of tags', max_length=128, null=True, verbose_name='Keyword Tags'),
),
migrations.AlterField(
model_name='searchable',
name='venue_name',
field=models.CharField(blank=True, max_length=256),
),
migrations.AlterField(
model_name='userprofile',
name='avatar',
field=models.URLField(blank=True, max_length=150, null=True, verbose_name='Photo Image'),
),
migrations.AddField(
model_name='event',
name='topics',
field=models.ManyToManyField(blank=True, to='events.Topic'),
),
migrations.AddField(
model_name='team',
name='categories',
field=models.ManyToManyField(blank=True, to='events.Category'),
),
migrations.AddField(
model_name='team',
name='topics',
field=models.ManyToManyField(blank=True, to='events.Topic'),
),
]

View file

@ -64,12 +64,14 @@ class Event(models.Model):
created_by = models.ForeignKey(UserProfile, on_delete=models.CASCADE)
created_time = models.DateTimeField(help_text=_('the date and time when the event was created'), default=datetime.datetime.now, db_index=True)
tags = models.CharField(verbose_name=_("Keyword Tags"), blank=True, null=True, max_length=128)
tags = models.CharField(verbose_name=_("Keyword Tags"), help_text=_('Comma-separates list of tags'), blank=True, null=True, max_length=128)
#image
#replies
attendees = models.ManyToManyField(UserProfile, through='Attendee', related_name="attending", blank=True)
topics = models.ManyToManyField('Topic', blank=True)
def get_absolute_url(self):
return reverse('show-event', kwargs={'event_id': self.id, 'event_slug': self.slug})

View file

@ -157,6 +157,9 @@ class Team(models.Model):
members = models.ManyToManyField(UserProfile, through='Member', related_name="memberships", blank=True)
categories = models.ManyToManyField('Category', blank=True)
topics = models.ManyToManyField('Topic', blank=True)
@property
def location_name(self):
if self.city: