repair_team_members.py (AEN 4.0)
================================

.. raw:: html

    <div class="section" id="repair-team-members-py">
    <h1>repair_team_members.py<a class="headerlink" href="#repair-team-members-py" title="Permalink to this headline">¶</a></h1>
    <div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">wk_server.base</span> <span class="k">import</span> <span class="n">init</span> <span class="k">as</span> <span class="n">wk_server_init</span>
    <span class="kn">from</span> <span class="nn">wk_server.tasks</span> <span class="k">import</span> <span class="n">add_team_member</span>
    <span class="kn">import</span> <span class="nn">wk_server.database</span> <span class="k">as</span> <span class="nn">db</span>

    <span class="n">wk_server_init</span><span class="p">()</span>

    <span class="n">users</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">get_users</span><span class="p">()</span>
    <span class="k">for</span> <span class="n">user</span> <span class="ow">in</span> <span class="n">users</span><span class="p">:</span>
      <span class="n">projects</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">get_projects</span><span class="p">(</span><span class="n">user</span><span class="p">,</span> <span class="n">user</span><span class="p">)</span>
      <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">projects</span><span class="p">:</span>
          <span class="k">if</span> <span class="ow">not</span> <span class="n">p</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;team&#39;</span><span class="p">):</span>
              <span class="k">continue</span>
          <span class="nb">print</span> <span class="n">user</span><span class="p">[</span><span class="s1">&#39;username&#39;</span><span class="p">],</span> <span class="n">p</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">],</span> <span class="n">p</span><span class="p">[</span><span class="s1">&#39;team&#39;</span><span class="p">]</span>
          <span class="k">for</span> <span class="n">team</span> <span class="ow">in</span> <span class="n">p</span><span class="p">[</span><span class="s1">&#39;team&#39;</span><span class="p">]:</span>
              <span class="n">team_member</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">get_user</span><span class="p">(</span><span class="n">_id</span><span class="o">=</span><span class="n">team</span><span class="p">)</span>
              <span class="nb">print</span> <span class="s1">&#39;adding&#39;</span><span class="p">,</span> <span class="n">user</span><span class="p">[</span><span class="s1">&#39;username&#39;</span><span class="p">],</span> <span class="n">p</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">],</span> <span class="n">p</span><span class="p">[</span><span class="s1">&#39;team&#39;</span><span class="p">],</span> <span class="n">team_member</span><span class="p">[</span><span class="s1">&#39;username&#39;</span><span class="p">]</span>
              <span class="n">add_team_member</span><span class="p">(</span><span class="n">user</span><span class="p">[</span><span class="s1">&#39;_id&#39;</span><span class="p">],</span> <span class="n">user</span><span class="p">[</span><span class="s1">&#39;_id&#39;</span><span class="p">],</span> <span class="n">p</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">],</span> <span class="n">team_member</span><span class="p">[</span><span class="s1">&#39;_id&#39;</span><span class="p">])</span>
    </pre></div>
    </div>
    </div>
