Commit eaed376a96539bab530e9fc8a89e93c202c2bd79

Authored by Matheus Lins
2 parents 02cbb3a1 713268ba

conflit

users/forms.py
@@ -69,10 +69,14 @@ class UpdateUserForm(forms.ModelForm): @@ -69,10 +69,14 @@ class UpdateUserForm(forms.ModelForm):
69 69
70 class Meta: 70 class Meta:
71 model = User 71 model = User
72 - fields = ['username', 'name', 'email', 'city', 'state', 'birth_date', 'gender', 'type_profile', 'cpf', 'phone', 'image', 'is_staff', 'is_active'] 72 + fields = ['username', 'name', 'email', 'birth_date', 'city',
  73 + 'state', 'gender', 'type_profile', 'cpf', 'phone', 'image', 'titration',
  74 + 'year_titration', 'institution', 'curriculum', 'is_staff', 'is_active']
73 75
74 class UpdateProfileForm(UpdateUserForm): 76 class UpdateProfileForm(UpdateUserForm):
75 77
76 class Meta: 78 class Meta:
77 model = User 79 model = User
78 - fields = ['username', 'name', 'email', 'birth_date', 'city', 'state', 'gender', 'cpf', 'phone', 'image', 'curriculum'] 80 + fields = ['username', 'name', 'email', 'birth_date', 'city',
  81 + 'state', 'gender', 'type_profile', 'cpf', 'phone', 'image', 'titration',
  82 + 'year_titration', 'institution', 'curriculum', 'is_staff', 'is_active']
users/templates/list_users.html
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
42 </div> 42 </div>
43 <div class="col-md-1 col-sm-1 col-xs-1"> 43 <div class="col-md-1 col-sm-1 col-xs-1">
44 <button type="submit" class="btn btn-fab btn-fab-mini"> 44 <button type="submit" class="btn btn-fab btn-fab-mini">
45 - <i class="material-icons">{% trans 'Search' %}</i> 45 + <i class="material-icons">search</i>
46 </button> 46 </button>
47 </div> 47 </div>
48 </div> 48 </div>
@@ -54,7 +54,7 @@ @@ -54,7 +54,7 @@
54 <div class="panel-body"> 54 <div class="panel-body">
55 <div class="col-md-4"> 55 <div class="col-md-4">
56 {% if acc.image %} 56 {% if acc.image %}
57 - <img src="{{ acc.image.url }}" alt="photoUser" class="img-circle img-responsive img-list-user"> 57 + <div style="background-image: url('{{ acc.image.url }}'); background-size: 100%" alt="photoUser" class="img-circle img-responsive img-list-user"></div>
58 {% else %} 58 {% else %}
59 {% if acc.gender == 'M' %} 59 {% if acc.gender == 'M' %}
60 <img src="{% static 'img/male_avatar.png' %}" alt="Avatar" class="img-circle img-responsive img-list-user"> 60 <img src="{% static 'img/male_avatar.png' %}" alt="Avatar" class="img-circle img-responsive img-list-user">
users/templates/users/edit_profile.html
1 -{% extends 'users/profile.html' %} 1 +{% extends 'list_users.html' %}
2 2
3 -{% load static i18n %} 3 +{% load static i18n permission_tags %}
4 {% load widget_tweaks %} 4 {% load widget_tweaks %}
  5 +
5 {% load django_bootstrap_breadcrumbs %} 6 {% load django_bootstrap_breadcrumbs %}
6 7
7 {% block breadcrumbs %} 8 {% block breadcrumbs %}
8 9
9 {{ block.super }} 10 {{ block.super }}
10 - {% breadcrumb 'Edit' 'users:update_profile' %} 11 + {% breadcrumb 'Update User' 'users:update' %}
11 12
12 {% endblock %} 13 {% endblock %}
13 14
  15 +
14 {% block content %} 16 {% block content %}
15 {% if messages %} 17 {% if messages %}
16 {% for message in messages %} 18 {% for message in messages %}
@@ -22,6 +24,7 @@ @@ -22,6 +24,7 @@
22 </div> 24 </div>
23 {% endfor %} 25 {% endfor %}
24 {% endif %} 26 {% endif %}
  27 +
25 <div class="card"> 28 <div class="card">
26 <div class="card-content"> 29 <div class="card-content">
27 <div class="card-body"> 30 <div class="card-body">
@@ -29,34 +32,48 @@ @@ -29,34 +32,48 @@
29 {% csrf_token %} 32 {% csrf_token %}
30 {% for field in form %} 33 {% for field in form %}
31 <div class="form-group{% if form.has_error %} has-error {% endif %} is-fileinput"> 34 <div class="form-group{% if form.has_error %} has-error {% endif %} is-fileinput">
32 - <label for="{{ field.auto_id }}">{{ field.label }}</label> 35 + {% if not field.auto_id == 'id_is_staff' and not field.auto_id == 'id_is_active' and not field.auto_id == 'id_type_profile' %}
  36 + <label for="{{ field.auto_id }}">{{ field.label }}</label>
  37 + {% endif %}
33 {% if field.auto_id == 'id_birth_date' %} 38 {% if field.auto_id == 'id_birth_date' %}
34 - <input type="text" class="form-control date-picker"name="{{field.name}}" value="{% if field.value.year %}{{field.value|date:'Y-m-d'}}{% else %}{{field.value}}{% endif %}" min="{{now|date:'Y-m-d'}}" id="{{ field.auto_id }}"> 39 + <input type="text" class="form-control date-picker"name="{{field.name}}" value="{% if field.value.year %}{{field.value|date:'m/d/Y'}}{% else %}{{field.value}}{% endif %}" min="{{now|date:'m/d/Y'}}" id="{{ field.auto_id }}">
35 <span id="helpBlock" class="help-block">{{ field.help_text }}</span> 40 <span id="helpBlock" class="help-block">{{ field.help_text }}</span>
36 - {% elif field.auto_id == 'id_image' %} 41 + {% elif field.auto_id == 'id_image' or field.auto_id == 'id_curriculum'%}
37 {% render_field field class='form-control input-sm' %} 42 {% render_field field class='form-control input-sm' %}
38 <div class="input-group"> 43 <div class="input-group">
39 - <input type="text" readonly="" class="form-control" placeholder="{% trans 'Choose your photo...' %}"> 44 + <input type="text" readonly="" class="form-control" placeholder="{% trans 'Choose your file...' %}">
40 <span class="input-group-btn input-group-sm"> 45 <span class="input-group-btn input-group-sm">
41 <button type="button" class="btn btn-fab btn-fab-mini"> 46 <button type="button" class="btn btn-fab btn-fab-mini">
42 <i class="material-icons">attach_file</i> 47 <i class="material-icons">attach_file</i>
43 </button> 48 </button>
44 </span> 49 </span>
45 </div> 50 </div>
46 - {% elif field.auto_id == 'id_is_staff' or field.auto_id == 'id_is_active' %}  
47 - <div class="checkbox">  
48 - <label>  
49 - {% render_field field type='checkbox' %}  
50 - </label>  
51 - </div>  
52 {% elif field.auto_id == 'id_cpf' %} 51 {% elif field.auto_id == 'id_cpf' %}
53 {% render_field field class='form-control' onkeypress='campoNumerico(this,event); formatarCpf(this,event);' %} 52 {% render_field field class='form-control' onkeypress='campoNumerico(this,event); formatarCpf(this,event);' %}
54 53
55 {% elif field.auto_id == 'id_phone' %} 54 {% elif field.auto_id == 'id_phone' %}
56 {% render_field field class='form-control' onkeypress='campoNumerico(this,event); formatarTelefone(this,event);' %} 55 {% render_field field class='form-control' onkeypress='campoNumerico(this,event); formatarTelefone(this,event);' %}
  56 +
  57 + {% elif field.auto_id == 'id_is_staff' or field.auto_id == 'id_is_active' %}
  58 + {% if user|has_role:'system_admin' %}
  59 + <label for="{{ field.auto_id }}">{{ field.label }}</label>
  60 + <div class="checkbox">
  61 + <label for="{{ field.auto_id }}">
  62 + {% render_field field %}<span class="checkbox-material"><span class="check"></span></span> {{field.label}}
  63 + </label>
  64 + </div>
  65 + {% endif %}
  66 + {% elif field.auto_id == 'id_type_profile' %}
  67 + {% if user|has_role:'system_admin' %}
  68 + <label for="{{ field.auto_id }}">{{ field.label }}</label>
  69 + {% render_field field class='form-control' %}
  70 + <span id="helpBlock" class="help-block">{{ field.help_text }}</span>
  71 + {% endif %}
57 {% else %} 72 {% else %}
58 - {% render_field field class='form-control' %}  
59 - <span id="helpBlock" class="help-block">{{ field.help_text }}</span> 73 + {% if not field.auto_id == 'id_is_staff' and not field.auto_id == 'id_is_active' and not field.auto_id == 'id_type_profile' %}
  74 + {% render_field field class='form-control' %}
  75 + <span id="helpBlock" class="help-block">{{ field.help_text }}</span>
  76 + {% endif %}
60 {% endif %} 77 {% endif %}
61 {% if field.errors %} 78 {% if field.errors %}
62 <div class="alert alert-danger alert-dismissible" role="alert"> 79 <div class="alert alert-danger alert-dismissible" role="alert">
@@ -72,16 +89,15 @@ @@ -72,16 +89,15 @@
72 {% endif %} 89 {% endif %}
73 </div> 90 </div>
74 {% endfor %} 91 {% endfor %}
75 - <div class="col-md-3 col-sm-2 col-xs-2">  
76 - <input type="submit" value="{% trans 'Save' %}" class="btn btn-raised btn-block btn-success" /> 92 + <div class="col-md-offset-2 col-md-2 col-sm-2 col-xs-2">
  93 + <input type="submit" value="{% trans 'Save' %}" class="btn btn-raised btn-success" />
77 </div> 94 </div>
78 - <div class="col-md-3 col-sm-2 col-xs-2">  
79 - <a href="{% url 'users:profile' %}" class="btn btn-raised btn-block btn-danger" >{% trans 'Cancel' %}</a> 95 + <div class="col-md-offset-3 col-md-2 col-sm-2 col-xs-2">
  96 + <a href="{% url 'users:profile' %}" class="btn btn-raised btn-danger" >{% trans 'Cancel' %}</a>
80 </div> 97 </div>
81 </form> 98 </form>
82 </div> 99 </div>
83 </div> 100 </div>
84 </div> 101 </div>
85 -  
86 <br clear="all" /> 102 <br clear="all" />
87 {% endblock %} 103 {% endblock %}
users/templates/users/update.html
@@ -34,12 +34,12 @@ @@ -34,12 +34,12 @@
34 <div class="form-group{% if form.has_error %} has-error {% endif %} is-fileinput"> 34 <div class="form-group{% if form.has_error %} has-error {% endif %} is-fileinput">
35 <label for="{{ field.auto_id }}">{{ field.label }}</label> 35 <label for="{{ field.auto_id }}">{{ field.label }}</label>
36 {% if field.auto_id == 'id_birth_date' %} 36 {% if field.auto_id == 'id_birth_date' %}
37 - <input type="text" class="form-control date-picker"name="{{field.name}}" value="{% if field.value.year %}{{field.value|date:'Y-m-d'}}{% else %}{{field.value}}{% endif %}" min="{{now|date:'Y-m-d'}}" id="{{ field.auto_id }}"> 37 + <input type="text" class="form-control date-picker"name="{{field.name}}" value="{% if field.value.year %}{{field.value|date:'m/d/Y'}}{% else %}{{field.value}}{% endif %}" min="{{now|date:'m/d/Y'}}" id="{{ field.auto_id }}">
38 <span id="helpBlock" class="help-block">{{ field.help_text }}</span> 38 <span id="helpBlock" class="help-block">{{ field.help_text }}</span>
39 - {% elif field.auto_id == 'id_image' %} 39 + {% elif field.auto_id == 'id_image' or field.auto_id == 'id_curriculum'%}
40 {% render_field field class='form-control input-sm' %} 40 {% render_field field class='form-control input-sm' %}
41 <div class="input-group"> 41 <div class="input-group">
42 - <input type="text" readonly="" class="form-control" placeholder="{% trans 'Choose your photo...' %}"> 42 + <input type="text" readonly="" class="form-control" placeholder="{% trans 'Choose your file...' %}">
43 <span class="input-group-btn input-group-sm"> 43 <span class="input-group-btn input-group-sm">
44 <button type="button" class="btn btn-fab btn-fab-mini"> 44 <button type="button" class="btn btn-fab btn-fab-mini">
45 <i class="material-icons">attach_file</i> 45 <i class="material-icons">attach_file</i>
@@ -63,7 +63,7 @@ @@ -63,7 +63,7 @@
63 <span id="helpBlock" class="help-block">{{ field.help_text }}</span> 63 <span id="helpBlock" class="help-block">{{ field.help_text }}</span>
64 {% endif %} 64 {% endif %}
65 {% if field.errors %} 65 {% if field.errors %}
66 - <div class="alert alert-danger alert-dismissible col-md-offset-4 col-md-8" role="alert"> 66 + <div class="alert alert-danger alert-dismissible" role="alert">
67 <button type="button" class="close" data-dismiss="alert" aria-label="Close"> 67 <button type="button" class="close" data-dismiss="alert" aria-label="Close">
68 <span aria-hidden="true">&times;</span> 68 <span aria-hidden="true">&times;</span>
69 </button> 69 </button>