nerosketch 8 years ago
parent
commit
16ba530adc
  1. 8
      abonapp/forms.py
  2. 3
      abonapp/templates/abonapp/peoples.html
  3. 2
      abonapp/views.py

8
abonapp/forms.py

@ -158,15 +158,15 @@ class ExportUsersForm(forms.Form):
('fio', _('fio')), ('fio', _('fio')),
('ip_address', _('Ip Address')), ('ip_address', _('Ip Address')),
('description', _('Comment')), ('description', _('Comment')),
('street', _('Street')),
('street__name', _('Street')),
('house', _('House')), ('house', _('House')),
('birth_day', _('birth day')), ('birth_day', _('birth day')),
('is_active', _('Is active')), ('is_active', _('Is active')),
('telephone', _('Telephone')), ('telephone', _('Telephone')),
('current_tariff', _('Service title')),
('current_tariff__tariff__title', _('Service title')),
('ballance', _('Ballance')), ('ballance', _('Ballance')),
('device', _('Device')),
('dev_port', _('Device port')),
('device__comment', _('Device')),
('dev_port__descr', _('Device port')),
('is_dynamic_ip', _('Is dynamic ip')) ('is_dynamic_ip', _('Is dynamic ip'))
) )
fields = forms.MultipleChoiceField(choices=FIELDS_CHOICES, fields = forms.MultipleChoiceField(choices=FIELDS_CHOICES,

3
abonapp/templates/abonapp/peoples.html

@ -136,6 +136,9 @@
<a href="{% url 'abonapp:phonebook' abon_group.pk %}" class="btn btn-default btn-modal"> <a href="{% url 'abonapp:phonebook' abon_group.pk %}" class="btn btn-default btn-modal">
<span class="glyphicon glyphicon-earphone"></span> {% trans 'Phonebook' %} <span class="glyphicon glyphicon-earphone"></span> {% trans 'Phonebook' %}
</a> </a>
<a href="{% url 'abonapp:abon_export' abon_group.pk %}" class="btn btn-default btn-modal">
<span class="glyphicon glyphicon-export"></span> {% trans 'Export users' %}
</a>
</td> </td>
</tr> </tr>
</tfoot> </tfoot>

2
abonapp/views.py

@ -923,6 +923,8 @@ def abon_export(request, gid):
response = HttpResponse(content_type='text/csv') response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename="users.csv"' response['Content-Disposition'] = 'attachment; filename="users.csv"'
writer = csv.writer(response, quoting=csv.QUOTE_NONNUMERIC) writer = csv.writer(response, quoting=csv.QUOTE_NONNUMERIC)
display_values = [f[1] for f in frm.fields['fields'].choices if f[0] in fields]
writer.writerow(display_values)
for row in subscribers: for row in subscribers:
writer.writerow(row) writer.writerow(row)
return response return response

Loading…
Cancel
Save