You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

24 lines
1019 B

from django.core.management.base import BaseCommand
from django.utils.translation import activate
from service.models import Service,LinkedService
from country.models import Country
from exposition.models import Exposition
from conference.models import Conference
class Command(BaseCommand):
def handle(self, *args, **options):
activate('ru')
LinkedService.objects.all().delete()
services = Service.objects.all()
for service in services:
linked = LinkedService()
linked.service = service
linked.save()
if Country.objects.language().filter(services=getattr(Country.services, service.url)).count() > 180:
linked.exclude_countries = True
linked.countries = Country.objects.language().exclude(services=getattr(Country.services, service.url))
else:
linked.countries = Country.objects.language().filter(services=getattr(Country.services, service.url))
linked.save()