class Meta:
model = UserProfile
- fields = ['items_per_page']
+ fields = ['items_per_page', 'show_ids']
+ labels = {
+ 'show_ids': 'Show Patch IDs:'
+ }
def _get_delegate_qs(project, instance=None):
--- /dev/null
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.6 on 2017-03-26 20:59
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('patchwork', '0018_add_event_model'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='userprofile',
+ name='show_ids',
+ field=models.BooleanField(default=False, help_text=b'Show click-to-copy patch IDs in the list view'),
+ ),
+ ]
items_per_page = models.PositiveIntegerField(
default=100, null=False, blank=False,
help_text='Number of items to display per page')
+ show_ids = models.BooleanField(
+ default=False,
+ help_text='Show click-to-copy patch IDs in the list view')
@property
def name(self):
e.preventDefault();
});
});
+
+{% if user.is_authenticated and user.profile.show_ids %}
+function copyToClipboard(patch_id) {
+ input = document.createElement('input');
+ input.setAttribute('type', 'text');
+ input.setAttribute('value', patch_id);
+ input = document.body.appendChild(input);
+ input.select();
+ document.execCommand('copy');
+ input.remove();
+}
+{% endif %}
</script>
<form method="post">
{% csrf_token %}
</th>
{% endif %}
+ {% if user.is_authenticated and user.profile.show_ids %}
+ <th>
+ ID
+ </th>
+ {% endif %}
+
<th>
{% ifequal order.name "name" %}
<a class="colactive" href="{% listurl order=order.reversed_name %}">
<input type="checkbox" name="patch_id:{{patch.id}}"/>
</td>
{% endif %}
+ {% if user.is_authenticated and user.profile.show_ids %}
+ <td>
+ <button type="button" class="btn btn-xs"
+ onClick="javascript:copyToClipboard('{{patch.id}}');"
+ title="Copy to Clipboard">{{ patch.id }}</button>
+ </td>
+ {% endif %}
<td>
<a href="{% url 'patch-detail' patch_id=patch.id %}">
{{ patch.name|default:"[no subject]"|truncatechars:100 }}