allow engine-specific Network views

This commit is contained in:
Andrew Grant committed 2022-06-18 04:26:23 -04:00
1 parent 4d57443b7b
commit a1db59d782
2 files changed
+18 -17

No files matched your search

+17 -16
View File
@@ -497,23 +497,24 @@ def newTest(request):
def networks(request, action=None, sha256=None, client=False): def networks(request, action=None, sha256=None, client=False):
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # *** GET Requests:
# # # [1] Fetch a view of all the Networks on the framework (/networks/)
# GET : There are three possible GET lookups. [1] Fetch a view of all # # [2] Fetch a view of all Networks for a given engine (/networks/<engine>/)
# the Networks on the framework. [2] Fetch a template to upload a # # [3] Download the contents of a Network if allowed (/networks/download/<sha256>/)
# new Network to the framework. [3] Download the contents of a # #
# Network that is already saved on the framework. Anyone may view # # *** POST Requests:
# the list of Network weights, but only some may interact # # [1] Upload a Network to the framework (/networks/upload/)
# # # [2] Set as default a Network on the framework (/networks/default/<sha256>/)
# POST : There are three possible POST lookups. They are Upload, Default # # [3] Delete a Network from the framework (/networks/delete/<sha256>/)
# and Delete. All of these are placed behind a login and approver # #
# flag wall. This view is not meant to distribute Networks # # *** Rights:
# # # Any user may look at the list of Networks, for all or some engines
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Only authenticated and approved Users may interact in the remaining ways
if action == None: if not action or action.upper() not in ['UPLOAD', 'DEFAULT', 'DELETE', 'DOWNLOAD']:
networks = Network.objects.all().order_by('-id') networks = Network.objects.all()
return render(request, 'networks.html', {'networks' : networks}) if action: networks = networks.filter(engine=action)
return render(request, 'networks.html', { 'networks' : networks.order_by('-id') })
if not request.user.is_authenticated: if not request.user.is_authenticated:
return django.http.HttpResponseRedirect('/login/') return django.http.HttpResponseRedirect('/login/')
+1 -1
View File
@@ -76,7 +76,7 @@
<i class="far fa-star" aria-hidden="true"></i></a></td> <i class="far fa-star" aria-hidden="true"></i></a></td>
{% endif %} {% endif %}
<td>{{network.engine}}</td> <td><a href="/networks/{{network.engine}}/">{{network.engine}}</a></td>
<td><a href="/user/{{network.author}}">{{network.author|capfirst}}</a></td> <td><a href="/user/{{network.author}}">{{network.author|capfirst}}</a></td>
<td><a href="/networks/download/{{network.sha256}}">{{network.name}}</a></td> <td><a href="/networks/download/{{network.sha256}}">{{network.name}}</a></td>
<td>{{network.sha256}}</td> <td>{{network.sha256}}</td>