-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metadata #110
base: master
Are you sure you want to change the base?
Metadata #110
Conversation
- Extract metadata and saved during upload
when next image selected
show image metadata with delete functions together
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please excuse the delay, I had forgotten about this.
Overall looks good I think, but there are some minor issues to be fixed.
The errors from CI are:
imagetagger/imagetagger/images/forms.py:3:1: F401 'imagetagger.images.models.Image' imported but unused
imagetagger/imagetagger/images/forms.py:14:1: W293 blank line contains whitespace
imagetagger/imagetagger/images/views.py:43:1: F811 redefinition of unused 'json' from line 29
imagetagger/imagetagger/images/views.py:213:1: W293 blank line contains whitespace
imagetagger/imagetagger/images/views.py:277:69: F821 undefined name 'image_file'
imagetagger/imagetagger/images/views.py:407:19: E222 multiple spaces after operator
imagetagger/imagetagger/images/views.py:412:1: E302 expected 2 blank lines, found 1
could you fix them also pleas?
I have not reviewed the changes due to the indention fixes on the template in detail.
imagetagger/imagetagger/annotations/static/annotations/js/annotations.js
Outdated
Show resolved
Hide resolved
Hi,
Sure, will update the commits accordingly.
Thank you for the update as well =)
From
Rayson
…On Mon, Jan 7, 2019 at 8:26 PM Nils Rokita ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Please excuse the delay, I had forgotten about this.
Overall looks good I think, but there are some minor issues to be fixed.
The errors from CI are:
imagetagger/imagetagger/images/forms.py:3:1: F401 'imagetagger.images.models.Image' imported but unused
imagetagger/imagetagger/images/forms.py:14:1: W293 blank line contains whitespace
imagetagger/imagetagger/images/views.py:43:1: F811 redefinition of unused 'json' from line 29
imagetagger/imagetagger/images/views.py:213:1: W293 blank line contains whitespace
imagetagger/imagetagger/images/views.py:277:69: F821 undefined name 'image_file'
imagetagger/imagetagger/images/views.py:407:19: E222 multiple spaces after operator
imagetagger/imagetagger/images/views.py:412:1: E302 expected 2 blank lines, found 1
could you fix them also pleas?
I have not reviewed the changes due to the indention fixes on the template
in detail.
------------------------------
In imagetagger/imagetagger/images/views.py
<#110 (comment)>:
> from imagetagger.users.forms import TeamCreationForm
from imagetagger.users.models import User, Team
from imagetagger.tagger_messages.forms import TeamMessageCreationForm
+import json
Json is already imported on line 43
------------------------------
In
imagetagger/imagetagger/annotations/static/annotations/js/annotations.js
<#110 (comment)>:
> @@ -17,6 +17,7 @@ globals = {
mouseDownY: undefined,
currentAnnotations: undefined,
allAnnotations: undefined,
+ allMetadata: undefined,
please fix the indention errors
------------------------------
In imagetagger/imagetagger/images/views.py
<#110 (comment)>:
> @@ -43,6 +45,35 @@
from datetime import date, timedelta
***@***.***_required
+def metadata_create(request):
+ if request.method == 'POST':
+ form = ImageMetadataForm(request.POST)
+ if form.is_valid():
+ data = request.POST
please do not use request.POST directly use form.cleaned_data
------------------------------
In imagetagger/imagetagger/images/views.py
<#110 (comment)>:
> + form = ImageMetadataForm(request.POST)
+ if form.is_valid():
+ data = request.POST
+ img = get_object_or_404(Image, pk=data['image'])
+ metadata = json.loads(img.metadata)
+ metadata[data['name']] = data['value']
+ img.metadata = json.dumps(metadata)
+ img.save()
+ messages.info(request,
+ _("Successfully updated \'{}\' in metadata".format(data['name'])))
+ return redirect(reverse('annotations:annotate', args=(img.pk,)))
+ return redirect(reverse('annotations:annotate', args=(request.POST['image'],)))
+
+
***@***.***_required
+def metadata_delete(request, image_id):
a @require_POST should be used, as this method has to be called via POST
------------------------------
In imagetagger/imagetagger/images/views.py
<#110 (comment)>:
> + img = get_object_or_404(Image, pk=data['image'])
+ metadata = json.loads(img.metadata)
+ metadata[data['name']] = data['value']
+ img.metadata = json.dumps(metadata)
+ img.save()
+ messages.info(request,
+ _("Successfully updated \'{}\' in metadata".format(data['name'])))
+ return redirect(reverse('annotations:annotate', args=(img.pk,)))
+ return redirect(reverse('annotations:annotate', args=(request.POST['image'],)))
+
+
***@***.***_required
+def metadata_delete(request, image_id):
+ img = get_object_or_404(Image, id=image_id)
+ metadata = json.loads(img.metadata)
+ metadata.pop(request.POST['key'])
What happens then the key does not (longer) exists
What if POST['key'] is not set and gives an exception?
------------------------------
In imagetagger/imagetagger/images/urls.py
<#110 (comment)>:
> @@ -9,6 +9,8 @@
url(r'^image/setfree/(\d+)/$', views.set_free, name='setfree_imageset'),
url(r'^image/upload/(\d+)/$', views.upload_image, name='upload_image'),
url(r'^image/(\d+)/$', views.view_image, name='view_image'),
+ url(r'^image/metadata/create', views.metadata_create, name='metadata_create'),
Please add a /$ ad the end of the url. (All urls should end with a /)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#110 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACATM44EV5UBl3RK1ucP4xq1TOi8SPqcks5vAzz1gaJpZM4ZTbRP>
.
|
@Akasch , thank you for the tips and guidance above, it is really helpful! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you change the two minor issues it should be good to merging
def metadata_delete(request, image_id): | ||
img = get_object_or_404(Image, id=image_id) | ||
metadata = json.loads(img.metadata) | ||
if request.POST['key'] in metadata: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if POST['key'] is not set an exception is thrown
return redirect(reverse('annotations:annotate', args=(request.POST['image'],))) | ||
|
||
|
||
@require_POST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@login_required is now missing here, just do both on seperate lines:
@login_required
@require_POST
def metadata_delete(request, image_id):
resolve #17 Include metadata to image level