Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Jan 15, 2024
1 parent b9cc0b7 commit 3ad3a55
Show file tree
Hide file tree
Showing 20 changed files with 57 additions and 765 deletions.
2 changes: 0 additions & 2 deletions _modules/apis_core/api_routers.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ <h1>Source code for apis_core.api_routers</h1><div class="highlight"><pre>
<span class="p">)</span>
<span class="kn">from</span> <span class="nn">drf_spectacular.types</span> <span class="kn">import</span> <span class="n">OpenApiTypes</span>
<span class="kn">from</span> <span class="nn">django_filters</span> <span class="kn">import</span> <span class="n">rest_framework</span> <span class="k">as</span> <span class="n">filters</span>
<span class="kn">from</span> <span class="nn">apis_core.apis_entities.models</span> <span class="kn">import</span> <span class="n">TempEntityClass</span>
<span class="kn">from</span> <span class="nn">.api_renderers</span> <span class="kn">import</span> <span class="n">NetJsonRenderer</span>
<span class="kn">from</span> <span class="nn">.apis_relations.models</span> <span class="kn">import</span> <span class="n">Triple</span><span class="p">,</span> <span class="n">Property</span>
<span class="kn">from</span> <span class="nn">apis_core.utils</span> <span class="kn">import</span> <span class="n">caching</span>
Expand Down Expand Up @@ -194,7 +193,6 @@ <h1>Source code for apis_core.api_routers</h1><div class="highlight"><pre>
<div class="viewcode-block" id="ApisBaseSerializer.Meta">
<a class="viewcode-back" href="../../modules/apis_core.html#apis_core.api_routers.ApisBaseSerializer.Meta">[docs]</a>
<span class="k">class</span> <span class="nc">Meta</span><span class="p">:</span>
<span class="n">model</span> <span class="o">=</span> <span class="n">TempEntityClass</span>
<span class="n">fields</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;id&quot;</span><span class="p">,</span> <span class="s2">&quot;label&quot;</span><span class="p">,</span> <span class="s2">&quot;url&quot;</span><span class="p">]</span></div>
</div>

Expand Down
14 changes: 1 addition & 13 deletions _modules/apis_core/apis_entities/detail_generic.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,8 @@ <h1>Source code for apis_core.apis_entities.detail_generic</h1><div class="highl
<span class="n">iiif_info_json</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">instance</span><span class="o">.</span><span class="n">name</span>

<span class="n">relevant_fields</span> <span class="o">=</span> <span class="p">[]</span>
<span class="c1"># those are fields from TempEntityClass, this exclude list can be removed once TempEntityClass is dropped</span>
<span class="n">exclude_fields</span> <span class="o">=</span> <span class="p">[</span>
<span class="s2">&quot;start_date&quot;</span><span class="p">,</span>
<span class="s2">&quot;start_start_date&quot;</span><span class="p">,</span>
<span class="s2">&quot;start_end_date&quot;</span><span class="p">,</span>
<span class="s2">&quot;end_date&quot;</span><span class="p">,</span>
<span class="s2">&quot;end_start_date&quot;</span><span class="p">,</span>
<span class="s2">&quot;end_end_date&quot;</span><span class="p">,</span>
<span class="s2">&quot;tempentityclass_ptr&quot;</span><span class="p">,</span>
<span class="s2">&quot;rootobject_ptr&quot;</span><span class="p">,</span>
<span class="s2">&quot;collection&quot;</span><span class="p">,</span>
<span class="p">]</span>
<span class="n">entity_settings</span> <span class="o">=</span> <span class="n">get_entity_settings_by_modelname</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">entity</span><span class="p">)</span>
<span class="n">exclude_fields</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">entity_settings</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;detail_view_exclude&quot;</span><span class="p">,</span> <span class="p">[]))</span>
<span class="n">exclude_fields</span> <span class="o">=</span> <span class="n">entity_settings</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;detail_view_exclude&quot;</span><span class="p">,</span> <span class="p">[])</span>
<span class="k">for</span> <span class="n">field</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">model_to_dict</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">instance</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="k">if</span> <span class="n">field</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">exclude_fields</span><span class="p">:</span>
<span class="n">relevant_fields</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="bp">self</span><span class="o">.</span><span class="n">instance</span><span class="o">.</span><span class="n">_meta</span><span class="o">.</span><span class="n">get_field</span><span class="p">(</span><span class="n">field</span><span class="p">),</span> <span class="n">value</span><span class="p">))</span>
Expand Down
2 changes: 0 additions & 2 deletions _modules/apis_core/apis_entities/filters.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ <h1>Source code for apis_core.apis_entities.filters</h1><div class="highlight"><
<span class="kn">from</span> <span class="nn">django.conf</span> <span class="kn">import</span> <span class="n">settings</span>
<span class="kn">from</span> <span class="nn">django.db.models</span> <span class="kn">import</span> <span class="n">JSONField</span>

<span class="kn">from</span> <span class="nn">apis_core.apis_entities.models</span> <span class="kn">import</span> <span class="n">TempEntityClass</span>
<span class="kn">from</span> <span class="nn">apis_core.utils</span> <span class="kn">import</span> <span class="n">caching</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.utils.filtermethods</span> <span class="kn">import</span> <span class="p">(</span>
Expand Down Expand Up @@ -146,7 +145,6 @@ <h1>Source code for apis_core.apis_entities.filters</h1><div class="highlight"><
<div class="viewcode-block" id="GenericEntityListFilter.Meta">
<a class="viewcode-back" href="../../../modules/apis_core.apis_entities.html#apis_core.apis_entities.filters.GenericEntityListFilter.Meta">[docs]</a>
<span class="k">class</span> <span class="nc">Meta</span><span class="p">:</span>
<span class="n">model</span> <span class="o">=</span> <span class="n">TempEntityClass</span>
<span class="c1"># exclude all hardcoded fields or nothing, however this exclude is only defined here as a temporary measure in</span>
<span class="c1"># order to load all filters of all model fields by default so that they are available in the first place.</span>
<span class="c1"># Later those which are not referenced in the settings file will be removed again</span>
Expand Down
64 changes: 0 additions & 64 deletions _modules/apis_core/apis_entities/forms.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,70 +189,6 @@ <h1>Source code for apis_core.apis_entities.forms</h1><div class="highlight"><pr
<span class="n">crispy_main_fields</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Field</span><span class="p">(</span><span class="n">field</span><span class="p">))</span>

<span class="bp">self</span><span class="o">.</span><span class="n">helper</span><span class="o">.</span><span class="n">layout</span> <span class="o">=</span> <span class="n">Layout</span><span class="p">(</span><span class="n">crispy_main_fields</span><span class="p">)</span>
<span class="c1"># backwards compatibility:</span>
<span class="c1"># those fields are part of TempEntityClass - this</span>
<span class="c1"># block can probably be removed when TempEntityClass</span>
<span class="c1"># is gone from apis_entities</span>
<span class="c1"># for now we at least check if they exist</span>
<span class="k">if</span> <span class="s2">&quot;status&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">[</span><span class="s2">&quot;status&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">required</span> <span class="o">=</span> <span class="kc">False</span>
<span class="k">if</span> <span class="s2">&quot;collection&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">[</span><span class="s2">&quot;collection&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">required</span> <span class="o">=</span> <span class="kc">False</span>
<span class="k">if</span> <span class="s2">&quot;start_date_written&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">[</span><span class="s2">&quot;start_date_written&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">required</span> <span class="o">=</span> <span class="kc">False</span>
<span class="k">if</span> <span class="s2">&quot;end_date_written&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">[</span><span class="s2">&quot;end_date_written&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">required</span> <span class="o">=</span> <span class="kc">False</span>

<span class="n">instance</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">&quot;instance&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
<span class="k">if</span> <span class="n">instance</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>

<span class="c1"># same as above, part of TempEntityClass</span>
<span class="k">if</span> <span class="s2">&quot;start_date_written&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">:</span>
<span class="k">if</span> <span class="n">instance</span><span class="o">.</span><span class="n">start_date_written</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">[</span>
<span class="s2">&quot;start_date_written&quot;</span>
<span class="p">]</span><span class="o">.</span><span class="n">help_text</span> <span class="o">=</span> <span class="n">DateParser</span><span class="o">.</span><span class="n">get_date_help_text_from_dates</span><span class="p">(</span>
<span class="n">single_date</span><span class="o">=</span><span class="n">instance</span><span class="o">.</span><span class="n">start_date</span><span class="p">,</span>
<span class="n">single_start_date</span><span class="o">=</span><span class="n">instance</span><span class="o">.</span><span class="n">start_start_date</span><span class="p">,</span>
<span class="n">single_end_date</span><span class="o">=</span><span class="n">instance</span><span class="o">.</span><span class="n">start_end_date</span><span class="p">,</span>
<span class="n">single_date_written</span><span class="o">=</span><span class="n">instance</span><span class="o">.</span><span class="n">start_date_written</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">[</span>
<span class="s2">&quot;start_date_written&quot;</span>
<span class="p">]</span><span class="o">.</span><span class="n">help_text</span> <span class="o">=</span> <span class="n">DateParser</span><span class="o">.</span><span class="n">get_date_help_text_default</span><span class="p">()</span>

<span class="c1"># same as above, part of TempEntityClass</span>
<span class="k">if</span> <span class="s2">&quot;end_date_written&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">:</span>
<span class="k">if</span> <span class="n">instance</span><span class="o">.</span><span class="n">end_date_written</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">[</span>
<span class="s2">&quot;end_date_written&quot;</span>
<span class="p">]</span><span class="o">.</span><span class="n">help_text</span> <span class="o">=</span> <span class="n">DateParser</span><span class="o">.</span><span class="n">get_date_help_text_from_dates</span><span class="p">(</span>
<span class="n">single_date</span><span class="o">=</span><span class="n">instance</span><span class="o">.</span><span class="n">end_date</span><span class="p">,</span>
<span class="n">single_start_date</span><span class="o">=</span><span class="n">instance</span><span class="o">.</span><span class="n">end_start_date</span><span class="p">,</span>
<span class="n">single_end_date</span><span class="o">=</span><span class="n">instance</span><span class="o">.</span><span class="n">end_end_date</span><span class="p">,</span>
<span class="n">single_date_written</span><span class="o">=</span><span class="n">instance</span><span class="o">.</span><span class="n">end_date_written</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">[</span>
<span class="s2">&quot;end_date_written&quot;</span>
<span class="p">]</span><span class="o">.</span><span class="n">help_text</span> <span class="o">=</span> <span class="n">DateParser</span><span class="o">.</span><span class="n">get_date_help_text_default</span><span class="p">()</span>

<span class="k">def</span> <span class="nf">save</span><span class="p">(</span><span class="bp">self</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">obj</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">GenericEntitiesForm</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">save</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="c1"># backwards compatibility</span>
<span class="c1"># collection is a field of TempEntityClass - this block</span>
<span class="c1"># can be removed when TempEntityClass is gone from apis_entities</span>
<span class="c1"># for now we at least check if the attribute exist</span>
<span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="s2">&quot;collection&quot;</span><span class="p">):</span>
<span class="k">if</span> <span class="n">obj</span><span class="o">.</span><span class="n">collection</span><span class="o">.</span><span class="n">all</span><span class="p">()</span><span class="o">.</span><span class="n">count</span><span class="p">()</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">col_name</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span>
<span class="n">settings</span><span class="p">,</span> <span class="s2">&quot;APIS_DEFAULT_COLLECTION&quot;</span><span class="p">,</span> <span class="s2">&quot;manually created entity&quot;</span>
<span class="p">)</span>
<span class="n">col</span><span class="p">,</span> <span class="n">created</span> <span class="o">=</span> <span class="n">Collection</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get_or_create</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">col_name</span><span class="p">)</span>
<span class="n">obj</span><span class="o">.</span><span class="n">collection</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">col</span><span class="p">)</span>
<span class="k">return</span> <span class="n">obj</span>

<span class="k">return</span> <span class="n">GenericEntitiesForm</span></div>

Expand Down
Loading

0 comments on commit 3ad3a55

Please sign in to comment.