parameters: (self, include_campaigns=True, include_triggers=False, include_archived=False)
return_statement: return dependencies
docstring: Generates a dict of all exportable flows and campaigns for this org with each object's immediate dependencies
docstring_summary: Generates a dict of all exportable flows and campaigns for this org with each object's immediate dependencies
docstring_tokens: Generates a dict of all exportable flows and campaigns for this org with each object s immediate dependencies
function: def generate_dependency_graph(self, include_campaigns=True, include_triggers=False, include_archived=False):
          """
          Generates a dict of all exportable flows and campaigns for this org with each object's immediate dependencies
          """
          from temba.campaigns.models import Campaign, CampaignEvent
          from temba.contacts.models import ContactGroup, ContactField
          from temba.flows.models import Flow
  
          campaign_prefetches = (
              Prefetch(
                  "events",
                  queryset=CampaignEvent.objects.filter(is_active=True).exclude(flow__is_system=True),
                  to_attr="flow_events",
              ),
              "flow_events__flow",
          )
  
          all_flows = self.flows.filter(is_active=True).exclude(is_system=True)
  
          if include_campaigns:
              all_campaigns = (
                  self.campaigns.filter(is_active=True).select_related("group").prefetch_related(*campaign_prefetches)
              )
          else:
              all_campaigns = Campaign.objects.none()
  
          if not include_archived:
              all_flows = all_flows.filter(is_archived=False)
              all_campaigns = all_campaigns.filter(is_archived=False)
  
          # build dependency graph for all flows and campaigns
          dependencies = defaultdict(set)
          for flow in all_flows:
              dependencies[flow] = flow.get_export_dependencies()
          for campaign in all_campaigns:
              dependencies[campaign] = set([e.flow for e in campaign.flow_events])
  
          # replace any dependency on a group with that group's associated campaigns - we're not actually interested
          # in flow-group-flow relationships - only relationships that go through a campaign
          campaigns_by_group = defaultdict(list)
          if include_campaigns:
              for campaign in self.campaigns.filter(is_active=True).select_related("group"):
                  campaigns_by_group[campaign.group].append(campaign)
  
          for c, deps in dependencies.items():
              if isinstance(c, Flow):
                  for d in list(deps):
                      # not interested in groups or fields for now
                      if isinstance(d, ContactField):
                          deps.remove(d)
                      if isinstance(d, ContactGroup):
                          deps.remove(d)
                          deps.update(campaigns_by_group[d])
  
          if include_triggers:
              all_triggers = self.triggers.filter(is_archived=False, is_active=True).select_related("flow")
              for trigger in all_triggers:
                  dependencies[trigger] = {trigger.flow}
  
          # make dependencies symmetric, i.e. if A depends on B, B depends on A
          for c, deps in dependencies.copy().items():
              for d in deps:
                  dependencies[d].add(c)
  
          return dependencies
function_tokens: def generate_dependency_graph ( self , include_campaigns = True , include_triggers = False , include_archived = False ) : from temba . campaigns . models import Campaign , CampaignEvent from temba . contacts . models import ContactGroup , ContactField from temba . flows . models import Flow campaign_prefetches = ( Prefetch ( "events" , queryset = CampaignEvent . objects . filter ( is_active = True ) . exclude ( flow__is_system = True ) , to_attr = "flow_events" , ) , "flow_events__flow" , ) all_flows = self . flows . filter ( is_active = True ) . exclude ( is_system = True ) if include_campaigns : all_campaigns = ( self . campaigns . filter ( is_active = True ) . select_related ( "group" ) . prefetch_related ( * campaign_prefetches ) ) else : all_campaigns = Campaign . objects . none ( ) if not include_archived : all_flows = all_flows . filter ( is_archived = False ) all_campaigns = all_campaigns . filter ( is_archived = False ) # build dependency graph for all flows and campaigns dependencies = defaultdict ( set ) for flow in all_flows : dependencies [ flow ] = flow . get_export_dependencies ( ) for campaign in all_campaigns : dependencies [ campaign ] = set ( [ e . flow for e in campaign . flow_events ] ) # replace any dependency on a group with that group's associated campaigns - we're not actually interested # in flow-group-flow relationships - only relationships that go through a campaign campaigns_by_group = defaultdict ( list ) if include_campaigns : for campaign in self . campaigns . filter ( is_active = True ) . select_related ( "group" ) : campaigns_by_group [ campaign . group ] . append ( campaign ) for c , deps in dependencies . items ( ) : if isinstance ( c , Flow ) : for d in list ( deps ) : # not interested in groups or fields for now if isinstance ( d , ContactField ) : deps . remove ( d ) if isinstance ( d , ContactGroup ) : deps . remove ( d ) deps . update ( campaigns_by_group [ d ] ) if include_triggers : all_triggers = self . triggers . filter ( is_archived = False , is_active = True ) . select_related ( "flow" ) for trigger in all_triggers : dependencies [ trigger ] = { trigger . flow } # make dependencies symmetric, i.e. if A depends on B, B depends on A for c , deps in dependencies . copy ( ) . items ( ) : for d in deps : dependencies [ d ] . add ( c ) return dependencies