#! /usr/bin/python
# -*- coding: utf-8 -*-

import sys, os, codecs

from django.core.management.base import BaseCommand

from dictionary.models import Entry
from semantics.models import SemanticFrame
from settings import PROJECT_PATH

class Command(BaseCommand):
    args = 'none'
    help = ''

    def handle(self, **options):
        connect_frames()

def connect_frames():
    entries = Entry.objects.all()
    for entry in entries:
        meanings = entry.meanings.all()
        for meaning in meanings:
            frames = meaning.frames.all()
            for frame in frames:
                frame.entry = entry
                frame.save()
                                
