diff --git a/uhepp_org/uhepp_vault/forms.py b/uhepp_org/uhepp_vault/forms.py index 1022de619ddaf18c0daeb6ab2e9aa56dae0c73c2..e892c0a0307551b02008d2ccc9123c3c3a149774 100644 --- a/uhepp_org/uhepp_vault/forms.py +++ b/uhepp_org/uhepp_vault/forms.py @@ -1,5 +1,6 @@ from django import forms from django.utils.translation import gettext_lazy as _ +from . import models class TokenForm(forms.Form): description = forms.CharField(label=_('Description'), max_length=100) @@ -22,3 +23,9 @@ class CollectionPermForm(forms.BaseForm): self.declared_fields = self.base_fields super().__init__(*args, **kwds) + +class PlotForm(forms.ModelForm): + class Meta: + model = models.Plot + fields = ["comment"] + diff --git a/uhepp_org/uhepp_vault/migrations/0009_auto_20210409_1516.py b/uhepp_org/uhepp_vault/migrations/0009_auto_20210409_1516.py new file mode 100644 index 0000000000000000000000000000000000000000..0e9b150780812a49ed341bf74fead01de6db9dd4 --- /dev/null +++ b/uhepp_org/uhepp_vault/migrations/0009_auto_20210409_1516.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.7 on 2021-04-09 15:16 + +from django.db import migrations, models +import django.db.models.functions.text + + +class Migration(migrations.Migration): + + dependencies = [ + ('uhepp_vault', '0008_auto_20210223_1620'), + ] + + operations = [ + migrations.AlterModelOptions( + name='collection', + options={'ordering': ['-activity', django.db.models.functions.text.Lower('title')]}, + ), + migrations.AddField( + model_name='plot', + name='comment', + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/uhepp_org/uhepp_vault/models.py b/uhepp_org/uhepp_vault/models.py index 4b54c9e2e92d0a0392168be0e6d44a7fe5c9986e..61404e3454d4eb5022448a9d76231205431e2e68 100644 --- a/uhepp_org/uhepp_vault/models.py +++ b/uhepp_org/uhepp_vault/models.py @@ -64,6 +64,7 @@ class Plot(models.Model): api_view_count = models.IntegerField(default=0) title = models.CharField(max_length=255, null=True, blank=True) uploaded = models.DateTimeField(auto_now_add=True) + comment = models.TextField(null=True, blank=True) collection = models.ForeignKey( Collection, diff --git a/uhepp_org/uhepp_vault/templates/uhepp_vault/plot_detail.html b/uhepp_org/uhepp_vault/templates/uhepp_vault/plot_detail.html index df1e857c7fcf395a86eea29bf515ff53f19b579e..50d470f9ced6a981ffd28ee8c6722049d2bd6dda 100644 --- a/uhepp_org/uhepp_vault/templates/uhepp_vault/plot_detail.html +++ b/uhepp_org/uhepp_vault/templates/uhepp_vault/plot_detail.html @@ -1,6 +1,7 @@ {% extends 'uhepp_vault/base.html' %} {% load pygmentify_tags %} {% load humanize %} +{% load crispy_forms_tags %} {% block title %}{{ plot.title }} - uhepp hub{% endblock %} @@ -29,6 +30,7 @@ </a> </span> {% endif %}</h1> + <div class="d-none d-lg-inline text-muted"> <i class="fas fa-eye"></i> {{ plot.view_count }} view{{ plot.view_count|pluralize }}, @@ -38,6 +40,7 @@ </span> </div> + <div class="d-flex"> <span class="d-none d-md-inline">UUID: {{ plot.uuid }}</span> <div class="ml-auto btn-group btn-group-sm access-menu"> @@ -122,6 +125,15 @@ uhepp push {{ plot.collection.pk }} local_file.json</pre> </div> </div> +<form method="POST" class="m-1 d-flex"> + <textarea name="comment" cols="40" class="textarea form-control" id="id_comment" rows="2"></textarea> + <div> + <button class="btn btn-outline-secondary"> + <i class="fas fa-save"></i> + </button> + </div> +</form> + <div id="app-root"> <div class="d-flex justify-content-center my-5"> diff --git a/uhepp_org/uhepp_vault/views.py b/uhepp_org/uhepp_vault/views.py index 529894c1ed8a2f4afd2556228fa5825ce8892379..28761d806ad154b6d348bf724d466b2397160935 100644 --- a/uhepp_org/uhepp_vault/views.py +++ b/uhepp_org/uhepp_vault/views.py @@ -19,7 +19,7 @@ from uhepp_api.masks import MaskRelatedColletions from .models import PUBLIC_LEVEL, INTERNAL_LEVEL, PUBLIC_LEVEL, \ Collection, Plot, Profile -from .forms import TokenForm +from .forms import TokenForm, PlotForm def quantize(value, sig_digits): if value <= 100: @@ -212,10 +212,12 @@ class PlotListView(generic.ListView): ) return queryset -class PlotDetail(generic.DetailView): +class PlotDetail(generic.UpdateView): model = Plot slug_field = 'uuid' slug_url_kwarg = 'uuid' + fields = ["comment"] + template_name = 'uhepp_vault/plot_detail.html' def get_queryset(self): if self.request.user.is_anonymous: