Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Jun 7, 2024
1 parent d11d33b commit 5cbe23f
Show file tree
Hide file tree
Showing 153 changed files with 478 additions and 652 deletions.
62 changes: 0 additions & 62 deletions _modules/apis_core/apis_entities/autocomplete3.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,77 +94,15 @@ <h1>Source code for apis_core.apis_entities.autocomplete3</h1><div class="highli
<span></span><span class="ch">#!/usr/bin/python</span>
<span class="c1"># -*- coding: utf-8 -*-</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">operator</span>
<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">reduce</span>

<span class="kn">from</span> <span class="nn">dal</span> <span class="kn">import</span> <span class="n">autocomplete</span>
<span class="kn">from</span> <span class="nn">django</span> <span class="kn">import</span> <span class="n">http</span>
<span class="kn">from</span> <span class="nn">django.contrib.contenttypes.models</span> <span class="kn">import</span> <span class="n">ContentType</span>
<span class="kn">from</span> <span class="nn">django.core.exceptions</span> <span class="kn">import</span> <span class="n">FieldError</span>
<span class="kn">from</span> <span class="nn">django.db.models</span> <span class="kn">import</span> <span class="n">Q</span>

<span class="kn">from</span> <span class="nn">apis_core.utils.settings</span> <span class="kn">import</span> <span class="n">get_entity_settings_by_modelname</span>
<span class="kn">from</span> <span class="nn">apis_core.apis_entities.utils</span> <span class="kn">import</span> <span class="n">get_entity_classes</span>
<span class="kn">from</span> <span class="nn">apis_core.apis_relations.models</span> <span class="kn">import</span> <span class="n">Property</span>


<span class="c1"># TODO RDF: Check if this should be removed or adapted</span>
<div class="viewcode-block" id="GenericNetworkEntitiesAutocomplete">
<a class="viewcode-back" href="../../../modules/apis_core.apis_entities.html#apis_core.apis_entities.autocomplete3.GenericNetworkEntitiesAutocomplete">[docs]</a>
<span class="k">class</span> <span class="nc">GenericNetworkEntitiesAutocomplete</span><span class="p">(</span><span class="n">autocomplete</span><span class="o">.</span><span class="n">Select2ListView</span><span class="p">):</span>
<div class="viewcode-block" id="GenericNetworkEntitiesAutocomplete.get">
<a class="viewcode-back" href="../../../modules/apis_core.apis_entities.html#apis_core.apis_entities.autocomplete3.GenericNetworkEntitiesAutocomplete.get">[docs]</a>
<span class="k">def</span> <span class="nf">get</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="n">entity</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;entity&quot;</span><span class="p">]</span>
<span class="n">q</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">q</span>
<span class="k">if</span> <span class="n">q</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;reg:&quot;</span><span class="p">):</span>
<span class="n">results</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">entity</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;person&quot;</span><span class="p">:</span>
<span class="n">filen</span> <span class="o">=</span> <span class="s2">&quot;reg_persons.json&quot;</span>
<span class="k">elif</span> <span class="n">entity</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;place&quot;</span><span class="p">:</span>
<span class="n">filen</span> <span class="o">=</span> <span class="s2">&quot;reg_places.json&quot;</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">filen</span><span class="p">,</span> <span class="s2">&quot;r&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">reg</span><span class="p">:</span>
<span class="n">r1</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">reg</span><span class="p">)</span>
<span class="n">r_dict</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">()</span>
<span class="k">for</span> <span class="n">r2</span> <span class="ow">in</span> <span class="n">r1</span><span class="p">:</span>
<span class="k">if</span> <span class="n">q</span><span class="p">[</span><span class="mi">4</span><span class="p">:]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="n">r2</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span>
<span class="k">if</span> <span class="n">r2</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="ow">in</span> <span class="n">r_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
<span class="n">r_dict</span><span class="p">[</span><span class="n">r2</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">+=</span> <span class="s2">&quot;|</span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">r2</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">r_dict</span><span class="p">[</span><span class="n">r2</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">r2</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">r_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
<span class="n">results</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="s2">&quot;id&quot;</span><span class="p">:</span> <span class="s2">&quot;reg:&quot;</span> <span class="o">+</span> <span class="n">r_dict</span><span class="p">[</span><span class="n">k</span><span class="p">],</span> <span class="s2">&quot;text&quot;</span><span class="p">:</span> <span class="n">k</span><span class="p">})</span>

<span class="k">else</span><span class="p">:</span>
<span class="n">ent_model</span> <span class="o">=</span> <span class="n">ContentType</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
<span class="n">app_label__startswith</span><span class="o">=</span><span class="s2">&quot;apis_&quot;</span><span class="p">,</span> <span class="n">model</span><span class="o">=</span><span class="n">entity</span>
<span class="p">)</span><span class="o">.</span><span class="n">model_class</span><span class="p">()</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">arg_list</span> <span class="o">=</span> <span class="p">[</span>
<span class="n">Q</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="n">x</span> <span class="o">+</span> <span class="s2">&quot;__icontains&quot;</span><span class="p">:</span> <span class="n">q</span><span class="p">})</span>
<span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">get_entity_settings_by_modelname</span><span class="p">(</span><span class="n">entity</span><span class="o">.</span><span class="n">title</span><span class="p">())</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
<span class="s2">&quot;search&quot;</span><span class="p">,</span> <span class="p">[]</span>
<span class="p">)</span>
<span class="p">]</span>
<span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
<span class="n">arg_list</span> <span class="o">=</span> <span class="p">[</span><span class="n">Q</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="n">x</span> <span class="o">+</span> <span class="s2">&quot;__icontains&quot;</span><span class="p">:</span> <span class="n">q</span><span class="p">})</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">]]</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">res</span> <span class="o">=</span> <span class="n">ent_model</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
<span class="n">reduce</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">or_</span><span class="p">,</span> <span class="n">arg_list</span><span class="p">)</span>
<span class="p">)</span><span class="o">.</span><span class="n">distinct</span><span class="p">()</span>
<span class="k">except</span> <span class="n">FieldError</span><span class="p">:</span>
<span class="n">arg_list</span> <span class="o">=</span> <span class="p">[</span><span class="n">Q</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="n">x</span> <span class="o">+</span> <span class="s2">&quot;__icontains&quot;</span><span class="p">:</span> <span class="n">q</span><span class="p">})</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;text&quot;</span><span class="p">]]</span>
<span class="n">res</span> <span class="o">=</span> <span class="n">ent_model</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
<span class="n">reduce</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">or_</span><span class="p">,</span> <span class="n">arg_list</span><span class="p">)</span>
<span class="p">)</span><span class="o">.</span><span class="n">distinct</span><span class="p">()</span>
<span class="n">results</span> <span class="o">=</span> <span class="p">[{</span><span class="s2">&quot;id&quot;</span><span class="p">:</span> <span class="n">x</span><span class="o">.</span><span class="n">pk</span><span class="p">,</span> <span class="s2">&quot;text&quot;</span><span class="p">:</span> <span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)}</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">res</span><span class="p">]</span>
<span class="k">return</span> <span class="n">http</span><span class="o">.</span><span class="n">HttpResponse</span><span class="p">(</span>
<span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">({</span><span class="s2">&quot;results&quot;</span><span class="p">:</span> <span class="n">results</span><span class="p">}),</span> <span class="n">content_type</span><span class="o">=</span><span class="s2">&quot;application/json&quot;</span>
<span class="p">)</span></div>
</div>



<div class="viewcode-block" id="PropertyAutocomplete">
<a class="viewcode-back" href="../../../modules/apis_core.apis_entities.html#apis_core.apis_entities.autocomplete3.PropertyAutocomplete">[docs]</a>
<span class="k">class</span> <span class="nc">PropertyAutocomplete</span><span class="p">(</span><span class="n">autocomplete</span><span class="o">.</span><span class="n">Select2ListView</span><span class="p">):</span>
Expand Down
9 changes: 0 additions & 9 deletions _modules/apis_core/apis_entities/urls.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ <h1>Source code for apis_core.apis_entities.urls</h1><div class="highlight"><pre
<span class="kn">from</span> <span class="nn">django.urls</span> <span class="kn">import</span> <span class="n">include</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">register_converter</span>
<span class="kn">from</span> <span class="nn">django.shortcuts</span> <span class="kn">import</span> <span class="n">get_list_or_404</span>

<span class="kn">from</span> <span class="nn">.autocomplete3</span> <span class="kn">import</span> <span class="p">(</span>
<span class="n">GenericNetworkEntitiesAutocomplete</span><span class="p">,</span>
<span class="p">)</span>

<span class="c1"># from .views import ReversionCompareView TODO: add again when import is fixed</span>
<span class="kn">from</span> <span class="nn">apis_core.apis_entities.models</span> <span class="kn">import</span> <span class="n">AbstractEntity</span>
<span class="kn">from</span> <span class="nn">apis_core.generic.views</span> <span class="kn">import</span> <span class="n">List</span><span class="p">,</span> <span class="n">Create</span><span class="p">,</span> <span class="n">Delete</span><span class="p">,</span> <span class="n">Detail</span>
Expand Down Expand Up @@ -191,11 +187,6 @@ <h1>Source code for apis_core.apis_entities.urls</h1><div class="highlight"><pre
<span class="s2">&quot;entity/&lt;entitytocontenttype:contenttype&gt;/&quot;</span><span class="p">,</span>
<span class="n">include</span><span class="p">(</span><span class="n">entity_patterns</span><span class="p">),</span>
<span class="p">),</span>
<span class="n">path</span><span class="p">(</span>
<span class="s2">&quot;autocomplete-network/&lt;slug:entity&gt;/&quot;</span><span class="p">,</span>
<span class="n">GenericNetworkEntitiesAutocomplete</span><span class="o">.</span><span class="n">as_view</span><span class="p">(),</span>
<span class="n">name</span><span class="o">=</span><span class="s2">&quot;generic_network_entities_autocomplete&quot;</span><span class="p">,</span>
<span class="p">),</span>
<span class="p">]</span>
</pre></div>

Expand Down
8 changes: 2 additions & 6 deletions genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -1349,8 +1349,6 @@ <h2 id="G">G</h2>
<li><a href="modules/apis_core.generic.forms.html#apis_core.generic.forms.GenericModelForm.Meta">GenericModelForm.Meta (class in apis_core.generic.forms)</a>
</li>
<li><a href="modules/apis_core.generic.html#apis_core.generic.views.GenericModelMixin">GenericModelMixin (class in apis_core.generic.views)</a>
</li>
<li><a href="modules/apis_core.apis_entities.html#apis_core.apis_entities.autocomplete3.GenericNetworkEntitiesAutocomplete">GenericNetworkEntitiesAutocomplete (class in apis_core.apis_entities.autocomplete3)</a>
</li>
<li><a href="modules/apis_core.apis_relations.html#apis_core.apis_relations.views.GenericRelationView">GenericRelationView (class in apis_core.apis_relations.views)</a>
</li>
Expand All @@ -1365,8 +1363,6 @@ <h2 id="G">G</h2>
<li><a href="modules/apis_core.apis_entities.html#apis_core.apis_entities.api_views.GetEntityGeneric.get">get() (apis_core.apis_entities.api_views.GetEntityGeneric method)</a>

<ul>
<li><a href="modules/apis_core.apis_entities.html#apis_core.apis_entities.autocomplete3.GenericNetworkEntitiesAutocomplete.get">(apis_core.apis_entities.autocomplete3.GenericNetworkEntitiesAutocomplete method)</a>
</li>
<li><a href="modules/apis_core.apis_entities.html#apis_core.apis_entities.autocomplete3.PropertyAutocomplete.get">(apis_core.apis_entities.autocomplete3.PropertyAutocomplete method)</a>
</li>
<li><a href="modules/apis_core.apis_entities.html#apis_core.apis_entities.views.EntitiesDuplicate.get">(apis_core.apis_entities.views.EntitiesDuplicate method)</a>
Expand Down Expand Up @@ -1462,10 +1458,10 @@ <h2 id="G">G</h2>
</li>
<li><a href="modules/apis_core.apis_entities.html#apis_core.apis_entities.utils.get_entity_classes">get_entity_classes() (in module apis_core.apis_entities.utils)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="modules/apis_core.apis_entities.html#apis_core.apis_entities.models.AbstractEntity.get_entity_list_filter">get_entity_list_filter() (apis_core.apis_entities.models.AbstractEntity class method)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="modules/apis_core.utils.html#apis_core.utils.settings.get_entity_settings_by_modelname">get_entity_settings_by_modelname() (in module apis_core.utils.settings)</a>
</li>
<li><a href="modules/apis_core.history.html#apis_core.history.serializers.ModelChangeSerializer.get_field_data">get_field_data() (apis_core.history.serializers.ModelChangeSerializer method)</a>
Expand Down
Loading

0 comments on commit 5cbe23f

Please sign in to comment.