diff --git a/abonapp/forms.py b/abonapp/forms.py index dbadb65..6f26e20 100644 --- a/abonapp/forms.py +++ b/abonapp/forms.py @@ -36,14 +36,17 @@ def generate_random_password(): class AbonForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(AbonForm, self).__init__(*args, **kwargs) - if self.instance is not None and self.instance.group is not None: - abon_group_queryset = models.AbonStreet.objects.filter(group=self.instance.group) + instance = getattr(self, 'instance') + if instance is not None and instance.group is not None: + abon_group_queryset = models.AbonStreet.objects.filter(group=instance.group) elif 'group' in self.initial.keys() and self.initial['group'] is not None: abon_group_queryset = models.AbonStreet.objects.filter(group=self.initial['group']) else: abon_group_queryset = None if abon_group_queryset is not None: self.fields['street'].queryset = abon_group_queryset + if instance is not None and instance.is_dynamic_ip: + self.fields['ip_address'].widget.attrs['readonly'] = True username = forms.CharField(max_length=127, required=False, initial=generate_random_username, widget=forms.TextInput(attrs={ diff --git a/abonapp/templates/abonapp/editAbon.html b/abonapp/templates/abonapp/editAbon.html index 1524d4c..993f6de 100644 --- a/abonapp/templates/abonapp/editAbon.html +++ b/abonapp/templates/abonapp/editAbon.html @@ -10,7 +10,12 @@

{% trans 'Change subscriber' %}

-
{% csrf_token %} + + {% if perms.abonapp.change_abon %} + {% url 'abonapp:abon_home' group.pk abon.username as ahlink %} + {% endif %} + + {% csrf_token %} {% bootstrap_field form.username label_class='col-sm-4' field_class='col-sm-8' form_group_class='form-group-sm' %} {% bootstrap_field form.fio label_class='col-sm-4' field_class='col-sm-8' form_group_class='form-group-sm' %} @@ -35,19 +40,19 @@
-
- -
-
- - - - - - -
-
-
+ {# Ip address field #} + {% trans 'Reset ip' as tx %} + {% url 'abonapp:reset_ip' group.pk abon.username as url %} + {% bootstrap_button '' button_type='link' icon='refresh' button_class='btn-default btn-cmd' id='iprefreshbtn' href=url size='sm' title=tx as bt %} + {% bootstrap_field form.ip_address label_class='col-sm-4' field_class='col-sm-8' form_group_class='form-group-sm' addon_after_class='input-group-btn' addon_after=bt %} + + {% bootstrap_field form.street label_class='col-sm-4' field_class='col-sm-8' form_group_class='form-group-sm' %} {% bootstrap_field form.house label_class='col-sm-4' field_class='col-sm-8' form_group_class='form-group-sm' %} @@ -74,11 +79,21 @@
{% trans 'Save' as tx %} - {% bootstrap_button tx button_type='submit' icon='floppy-disk' button_class='btn-primary' %} + {% if perms.abonapp.change_abon %} + {% bootstrap_button tx button_type='submit' icon='floppy-disk' button_class='btn-primary' %} + {% else %} + {% bootstrap_button tx button_type='button' icon='floppy-disk' button_class='btn-primary disabled' %} + {% endif %} {% if perms.taskapp.add_task %} - + + + + {% else %} + + + {% endif %}
@@ -86,10 +101,16 @@
- {% if ip and perms.abonapp.can_ping %} - - Ping - + {% if form.ip_address.value %} + {% if perms.abonapp.can_ping %} + + Ping + + {% else %} + + Ping + + {% endif %} {% else %} {% trans 'No have ip' %} @@ -100,6 +121,10 @@ {% trans 'Send sms' %} + {% else %} + + {% trans 'Send sms' %} + {% endif %}
diff --git a/abonapp/templates/abonapp/viewAbon.html b/abonapp/templates/abonapp/viewAbon.html deleted file mode 100644 index 47f5869..0000000 --- a/abonapp/templates/abonapp/viewAbon.html +++ /dev/null @@ -1,78 +0,0 @@ -{% extends request.is_ajax|yesno:'nullcont.htm,abonapp/ext.htm' %} -{% load i18n %} -{% block content %} - -
-
- -
-
-

{% trans 'View the subscriber' %}

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{% trans 'User group' %} - {{ abon.group|default:_('Not assigned') }} -
{% trans 'Is active' %} - {{ abon.is_active|yesno:_('yes,no') }} -
{% trans 'login' %}{{ abon.username|default:_('Not assigned') }}
{% trans 'fio' %}{{ abon.fio|default:_('Not assigned') }}
{% trans 'Telephone' %}{{ abon.telephone|default:_('Not assigned') }}
{% trans 'Street' %} - {{ abon.street|default:_('Not assigned') }} -
{% trans 'House' %}{{ abon.house|default:_('Not assigned') }}
{% trans 'Ip Address' %}{{ abon.ip_address|default:_('Not assigned') }}
{% trans 'Password' %}{{ passw }}
- {% if abon.description %}

{{ abon.description }}

{% endif %} -
-
- -
-
-
-
-

{% trans 'User flags' %}

-
-
- {% for user_icon in abon.get_flag_icons %} - - {% endfor %} -
-
-
-
- -{% endblock %} \ No newline at end of file