fix: add new search rule to correct group community lists ()

This commit is contained in:
Robert Sparks 2022-07-28 09:13:29 -05:00 committed by GitHub
parent 2c522ee169
commit 23fc0ea44a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,12 +6,13 @@ from django.db import migrations
def forward(apps, schema_editor):
SearchRule = apps.get_model('community', 'SearchRule')
CommunityList = apps.get_model('community', 'CommunityList')
Group = apps.get_model('group', 'Group')
State = apps.get_model('doc', 'State')
for group in Group.objects.filter(type_id__in=['wg','rg'], state_id='active'):
Rule = SearchRule.objects.filter(group = group)
if Rule.exists():
SearchRule.objects.create(community_list=Rule[0].community_list, rule_type="group_exp", group=group, state=State.objects.get(slug="expired", type="draft"),)
com_list = CommunityList.objects.filter(group=group).first()
if com_list is not None:
SearchRule.objects.create(community_list=com_list, rule_type="group_exp", group=group, state=State.objects.get(slug="expired", type="draft"),)
def reverse(apps, schema_editor):