Skip to content

Commit a071dee

Browse files
committed
Create and update project notes
Signed-off-by: Priya Pahwa <pahwa.priya19@gmail.com>
1 parent 8ce5985 commit a071dee

8 files changed

Lines changed: 131 additions & 0 deletions

File tree

scanpipe/forms.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,12 @@ class Meta:
106106
"input_files",
107107
"input_urls",
108108
"pipeline",
109+
"note",
109110
"execute_now",
110111
]
112+
widgets = {
113+
"note": forms.Textarea(attrs={"rows": 4, "cols": 63}),
114+
}
111115

112116
def __init__(self, *args, **kwargs):
113117
super().__init__(*args, **kwargs)
@@ -162,3 +166,12 @@ class ArchiveProjectForm(forms.Form):
162166
initial=False,
163167
required=False,
164168
)
169+
170+
171+
class ProjectNoteUpdateForm(forms.ModelForm):
172+
class Meta:
173+
model = Project
174+
fields = ("note",)
175+
widgets = {
176+
"note": forms.Textarea(attrs={"rows": 15, "cols": 111}),
177+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 4.0.4 on 2022-04-24 10:06
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('scanpipe', '0015_alter_codebaseresource_project_and_more'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='project',
15+
name='note',
16+
field=models.TextField(blank=True, null=True),
17+
),
18+
]

scanpipe/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ class Project(UUIDPKModel, ExtraDataFieldMixin, models.Model):
415415
"happened during the archive operation."
416416
),
417417
)
418+
note = models.TextField(null=True, blank=True)
418419

419420
class Meta:
420421
ordering = ["-created_date"]

scanpipe/templates/scanpipe/project_detail.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@
8181
</div>
8282
</section>
8383

84+
<section class="section pt-0 pb-5">
85+
{% if project.note %}
86+
<article class="message is-info">
87+
<div class="message-body">
88+
Note: {{ project.note }}
89+
<p style="text-align:right; bottom:0"><a href="{% url 'project_note_edit' project.uuid %}">Edit Note</a></p>
90+
</div>
91+
</article>
92+
</section>
93+
{% endif %}
94+
8495
{% if project.extra_data %}
8596
<article id="project-extra-data" class="panel is-info mx-5">
8697
<p class="panel-heading py-2 is-size-6">

scanpipe/templates/scanpipe/project_form.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ <h2 class="subtitle mb-0 pt-2 mb-5">
6565
</div>
6666
</div>
6767

68+
<div class="field">
69+
<label class="label" for="{{ form.note.id_for_label }}">{{ form.note.label }}</label>
70+
<div class="control">
71+
{{ form.note }}
72+
</div>
73+
</div>
74+
6875
<div class="field">
6976
<label class="checkbox" for="{{ form.execute_now.id_for_label }}">
7077
{{ form.execute_now }}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{% extends "scanpipe/base.html" %}
2+
{% load static humanize %}
3+
4+
{% block title %}ScanCode.io: {{ project.name }}{% endblock %}
5+
6+
{% block extrahead %}
7+
<link rel="stylesheet" href="{% static 'billboard-3.0.1-datalab.min.css' %}" crossorigin="anonymous" />
8+
{% endblock %}
9+
10+
{% block content %}
11+
<div class="container is-max-desktop">
12+
{% include 'scanpipe/includes/navbar_header.html' %}
13+
<div class="mx-5 mb-2">{% include 'scanpipe/includes/messages.html' %}</div>
14+
15+
<section class="mx-5 mb-3">
16+
{% include 'scanpipe/includes/breadcrumb.html' %}
17+
<div class="subtitle is-size-6">
18+
<span title="{{ project.created_date|date:'N j, Y, P T' }}">Created {{ project.created_date|naturaltime }}</span>
19+
{% include "scanpipe/includes/project_actions_dropdown.html" %}
20+
</div>
21+
</section>
22+
{% if not project.is_archived %}
23+
{% include "scanpipe/includes/project_archive_modal.html" %}
24+
{% endif %}
25+
{% include "scanpipe/includes/project_reset_modal.html" %}
26+
{% include "scanpipe/includes/project_delete_modal.html" %}
27+
28+
<div class="container mx-5 mb-5">
29+
<div class="field is-grouped is-grouped-multiline">
30+
<div class="control">
31+
<div class="tags has-addons">
32+
<span class="tag is-dark">UUID</span>
33+
<span class="tag is-info">{{ project.uuid }}</span>
34+
</div>
35+
</div>
36+
<div class="control">
37+
<div class="tags has-addons">
38+
<span class="tag is-dark">Work directory</span>
39+
<span class="tag is-info">{{ project.work_directory }}</span>
40+
</div>
41+
</div>
42+
</div>
43+
</div>
44+
45+
<section class="section pt-0">
46+
<h2 class="subtitle mb-0 pt-2 mb-5">
47+
Edit a <strong>Project Note</strong>
48+
</h2>
49+
<form method="post" enctype="multipart/form-data">{% csrf_token %}
50+
<div class="field">
51+
<label class="label" for="{{ form.note.id_for_label }}">{{ form.note.label }}</label>
52+
<div class="control">
53+
{{ form.note }}
54+
</div>
55+
</div>
56+
57+
<div class="columns mt-6 is-variable is-1">
58+
<div class="column">
59+
<input type="submit" class="button is-fullwidth is-link" value="Update">
60+
</div>
61+
</div>
62+
</form>
63+
</section>
64+
65+
{% endblock content %}

scanpipe/urls.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,9 @@
117117
name="project_list",
118118
),
119119
path("monitor/", include("django_rq.urls")),
120+
path(
121+
"project/<uuid:uuid>/edit/",
122+
views.ProjectNoteUpdateView.as_view(),
123+
name="project_note_edit",
124+
),
120125
]

scanpipe/views.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# ScanCode.io is a free software code scanning tool from nexB Inc. and others.
2121
# Visit https://github.com/nexB/scancode.io for support and download.
2222

23+
import uuid
2324
from collections import Counter
2425

2526
from django.apps import apps
@@ -35,6 +36,7 @@
3536
from django.views import generic
3637
from django.views.generic.detail import SingleObjectMixin
3738
from django.views.generic.edit import FormView
39+
from django.views.generic.edit import UpdateView
3840

3941
import saneyaml
4042
from django_filters.views import FilterView
@@ -49,6 +51,7 @@
4951
from scanpipe.forms import AddPipelineForm
5052
from scanpipe.forms import ArchiveProjectForm
5153
from scanpipe.forms import ProjectForm
54+
from scanpipe.forms import ProjectNoteUpdateForm
5255
from scanpipe.models import CodebaseResource
5356
from scanpipe.models import DiscoveredPackage
5457
from scanpipe.models import Project
@@ -591,3 +594,11 @@ def get(self, request, *args, **kwargs):
591594
)
592595

593596
raise Http404
597+
598+
599+
class ProjectNoteUpdateView(UpdateView):
600+
model = Project
601+
template_name = "scanpipe/project_note_edit.html"
602+
slug_field = "uuid"
603+
slug_url_kwarg = "uuid"
604+
form_class = ProjectNoteUpdateForm

0 commit comments

Comments
 (0)