fix: add new search rule to correct group community lists (#4291)
This commit is contained in:
parent
2c522ee169
commit
23fc0ea44a
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue