Skip to content

Commit

Permalink
Merge pull request #312 from memeLab/#261
Browse files Browse the repository at this point in the history
Let the user set a name to markers and objects when creating them. Also, show marker, object and artwork's names when clicking on it
  • Loading branch information
vjpixel authored Feb 14, 2020
2 parents d31e1df + 29b7d8f commit 5e7c4a2
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 8 deletions.
19 changes: 19 additions & 0 deletions src/ARte/core/migrations/0003_auto_20200213_1934.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.0 on 2020-02-13 19:34

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('core', '0002_exhibit_creation_date'),
]

operations = [
migrations.AlterField(
model_name='exhibit',
name='owner',
field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='exhibits', to='users.Profile'),
),
]
5 changes: 4 additions & 1 deletion src/ARte/users/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def __init__(self, *args, **kwargs):
self.fields['patt'].widget.attrs['placeholder'] = _('browse file')
self.fields['patt'].widget.attrs['accept'] = '.patt'
self.fields['author'].widget.attrs['placeholder'] = _('declare different author name')

self.fields['title'].widget.attrs['placeholder'] = _("Marker's title")

class Meta:
model = Marker
exclude = ('owner', 'uploaded_at')
Expand All @@ -189,6 +190,8 @@ def __init__(self, *args, **kwargs):
self.fields['scale'].widget = HiddenInput()
self.fields['rotation'].widget = HiddenInput()
self.fields['position'].widget = HiddenInput()
self.fields['title'].widget.attrs['placeholder'] = _("Object's title")
log.warning(self.fields)

class Meta:
model = Object
Expand Down
10 changes: 9 additions & 1 deletion src/ARte/users/jinja2/users/components/elements-modal.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@
function fillModal(element){
let elemType = element.attr('data-elem-type');
$('#modal-title').text({{ _("This is a Jandig ")|tojson }} + elemType);
let title = element.attr('title')
if(!title) {
$('#modal-title').text({{ _("This is a Jandig ")|tojson }} + elemType);
} else if (title != '') {
$('#modal-title').text(title);
} else {
$('#modal-title').text({{ _("This is a Jandig ")|tojson }} + elemType);
}
let elemUrl = {{url('element-get')|tojson}};
elemUrl += ("?" + elemType + "_id=" + element.attr('id'));
Expand Down
24 changes: 18 additions & 6 deletions src/ARte/users/jinja2/users/components/item-list.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<div id="{{ element_type }}-{{ element.id }}" class="repository-item">
{% if element_type == "marker" or element_type == "object" %}
{% if element.source.url.split('.')[1] == "mp4" or element.source.url.split('.')[1] == "webm" %}
<video id="{{ element.id }}" class="trigger-modal" data-elem-type="{{element_type}}" src="{{ element.source.url }}" height="50" width="50" muted autoplay loop>
<video id="{{ element.id }}" title="{{ element.title }}" class="trigger-modal" data-elem-type="{{element_type}}" src="{{ element.source.url }}" height="50" width="50" muted autoplay loop>
{% else %}
<img id="{{ element.id }}" class="trigger-modal" data-elem-type="{{element_type}}" src="{{ element.source.url }}" height="50" width="50">
<img id="{{ element.id }}" title="{{ element.title }}" class="trigger-modal" data-elem-type="{{element_type}}" src="{{ element.source.url }}" height="50" width="50">
{% endif %}
{% if deletable == True and not element.in_use %}
{% if element_type == "marker" %}
Expand All @@ -23,12 +23,24 @@
{% endif %}
{% elif element_type == "artwork" %}
<div class="artwork-elements flex">
<img id="{{ element.id }}" class="trigger-modal" data-elem-type="{{element_type}}" src="{{ element.marker.source.url }}" height="50" width="50">
{% if element.title %}
<img id="{{ element.id }}" title="{{ element.title }}" class="trigger-modal" data-elem-type="{{element_type}}" src="{{ element.marker.source.url }}" height="50" width="50">
{% else %}
<img id="{{ element.id }}" class="trigger-modal" data-elem-type="{{element_type}}" src="{{ element.marker.source.url }}" height="50" width="50">
{% endif %}
<div class="separator"></div>
{% if element.augmented.source.url.split('.')[1] == "mp4" or element.augmented.source.url.split('.')[1] == "webm" %}
<video id="{{ element.id }}" class="trigger-modal" data-elem-type="{{element_type}}" src="{{ element.augmented.source.url }}" height="50" width="50" muted autoplay loop>
{% else %}
<img id="{{ element.id }}" class="trigger-modal" data-elem-type="{{element_type}}" src="{{ element.augmented.source.url }}" height="50" width="50">
{% if element.title %}
<video id="{{ element.id }}" title="{{ element.title }}" class="trigger-modal" data-elem-type="{{element_type}}" src="{{ element.augmented.source.url }}" height="50" width="50" muted autoplay loop>
{% else %}
<video id="{{ element.id }}" class="trigger-modal" data-elem-type="{{element_type}}" src="{{ element.augmented.source.url }}" height="50" width="50" muted autoplay loop>
{% endif %}
{% else %}
{% if element.title %}
<img id="{{ element.id }}" title="{{ element.title }}" class="trigger-modal" data-elem-type="{{element_type}}" src="{{ element.augmented.source.url }}" height="50" width="50">
{% else %}
<img id="{{ element.id }}" class="trigger-modal" data-elem-type="{{element_type}}" src="{{ element.augmented.source.url }}" height="50" width="50">
{% endif %}
{% endif %}
{% if editable == True %}
<a href="{{ url('edit-artwork') }}?id={{element.id}}" class="edit">edit</a>
Expand Down
4 changes: 4 additions & 0 deletions src/ARte/users/jinja2/users/upload.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
{% if form_type == 'object' %}
{# <button id="edit_attrs_btn" value="{{_('Change scale, rotation and position')}}">
<div id="edit_object_attributes"> #}
{{ form.visible_fields()[2] }}
{{ form.visible_fields()[2].errors }}
<h2>{{_("Adjust scale")}}</h2>
<h3>X</h3>
<input id = "X-scale" class="trigger-change-value" value ="1">
Expand Down Expand Up @@ -62,6 +64,8 @@
{% if form_type == 'marker' %}
<h3>{{ _('Choose .patt file') }}</h3>
<div class="upload-field" id="patt-field">
{{ form.visible_fields()[3] }}
{{ form.visible_fields()[3].errors }}
{{ form.visible_fields()[2] }}
{{ form.visible_fields()[2].errors }}
</div>
Expand Down
40 changes: 40 additions & 0 deletions src/ARte/users/migrations/0006_auto_20200213_1934.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 2.0 on 2020-02-13 19:34

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('users', '0005_object_source_20200130_1904'),
]

operations = [
migrations.AddField(
model_name='marker',
name='title',
field=models.CharField(default='', max_length=60),
),
migrations.AddField(
model_name='object',
name='title',
field=models.CharField(default='', max_length=60),
),
migrations.AlterField(
model_name='marker',
name='owner',
field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='users.Profile'),
),
migrations.AlterField(
model_name='object',
name='owner',
field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='users.Profile'),
),
migrations.AlterField(
model_name='profile',
name='user',
field=models.OneToOneField(on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL),
),
]
2 changes: 2 additions & 0 deletions src/ARte/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Marker(models.Model):
source = models.ImageField(upload_to='markers/')
uploaded_at = models.DateTimeField(auto_now=True)
author = models.CharField(max_length=60, blank=False)
title = models.CharField(max_length=60, default='')
patt = models.FileField(upload_to='patts/')
def __str__(self):
return self.source.name
Expand All @@ -54,6 +55,7 @@ class Object(models.Model):
source = models.FileField(upload_to='objects/')
uploaded_at = models.DateTimeField(auto_now=True)
author = models.CharField(max_length=60, blank=False)
title = models.CharField(max_length=60, default='')
scale = models.CharField(default="1 1", max_length=50)
position = models.CharField(default="0 0 0", max_length=50)
rotation = models.CharField(default="270 0 0", max_length=50)
Expand Down

0 comments on commit 5e7c4a2

Please sign in to comment.