~hristoast/modding-openmw.com

58b72bf40fe93b26f43450778be2ee55fc1918d4 — Hristos N. Triantafillou 13 days ago 03e7991
Make this actually work
2 files changed, 42 insertions(+), 13 deletions(-)

M momw/momw/templates/all_plugins.html
M momw/momw/views/dynamicpages.py
M momw/momw/templates/all_plugins.html => momw/momw/templates/all_plugins.html +16 -5
@@ 2,10 2,21 @@
{% block title %}All Plugins{% endblock %}
{% block content %}

  <pre><code>
{% for k, v in plugins.items %}
{{ k }} {{ v }}
{% endfor %}
  </code></pre>
  <p>This is a testing page</p>

{% comment %}
<pre><code>{% for k, v in bsas.items %}{{ k }} {{ v }}
{% endfor %}</code></pre>

<pre><code>{% for k, v in plugins.items %}{{ k }} {{ v }}
{% endfor %}</code></pre>

<pre><code>{% for v in bsas.values %}{{ v }}
{% endfor %}</code></pre>
{% endcomment %}

<pre><code>{% for v in plugins.values %}content={{ v }}
{% endfor %}</code></pre>


{% endblock %}

M momw/momw/views/dynamicpages.py => momw/momw/views/dynamicpages.py +26 -8
@@ 1,4 1,3 @@
from collections import OrderedDict
from django.conf import settings
from django.http import Http404
from django.shortcuts import get_object_or_404, redirect, render


@@ 19,13 18,32 @@ def all_mods(request):

@cache_page(settings.CACHE_MIDDLEWARE_SECONDS)
def all_plugins(request):
    mods = Mod.with_plugins.all()
    plugins = OrderedDict()
    for m in mods:
        for k, v in m.has_plugin.items():
            plugins[k] = v
    print(plugins)
    return render(request, "all_plugins.html", {"plugins": plugins})
    bsa_mods = Mod.objects.exclude(has_bsa__exact={})
    plugin_mods = Mod.objects.all()

    bsas = {}
    _plugins = {}

    for m in bsa_mods:
        if isinstance(m.has_bsa, dict):
            for k in m.has_bsa.keys():
                bsas.update(m.has_bsa.items())

    for m in plugin_mods:
        if isinstance(m.has_plugin, dict):
            d = m.has_plugin.items()
            if d:
                for k, v in d:
                    if "# NOTE: " not in v:
                        if v.startswith("# "):
                            v = v.replace("# ", "")
                        _plugins.update({k: v})

    plugins = {}
    for k in sorted(_plugins.keys()):
        plugins.update({k: _plugins[k]})

    return render(request, "all_plugins.html", {"bsas": bsas, "plugins": plugins})


@cache_page(settings.CACHE_MIDDLEWARE_SECONDS)