From d22ea8df7d5c31c892dae087d1c4c09eb2d594ad Mon Sep 17 00:00:00 2001 From: Ashwin Date: Mon, 4 Feb 2019 14:57:39 +0530 Subject: [PATCH] added user view page --- common/forms.py | 2 +- common/templates/create.html | 1 - common/templates/list.html | 2 +- common/templates/user_detail.html | 609 ++++++++++++++++++++++++++++++ common/views.py | 16 +- static/css/main.scss | 4 +- 6 files changed, 624 insertions(+), 10 deletions(-) create mode 100644 common/templates/user_detail.html diff --git a/common/forms.py b/common/forms.py index 1e8577e2..1f1a1742 100644 --- a/common/forms.py +++ b/common/forms.py @@ -149,4 +149,4 @@ class DocumentForm(forms.ModelForm): class Meta: model = Document - fields = ['title', 'document_file'] \ No newline at end of file + fields = ['title', 'document_file'] diff --git a/common/templates/create.html b/common/templates/create.html index fa278316..81f21eb9 100644 --- a/common/templates/create.html +++ b/common/templates/create.html @@ -117,6 +117,5 @@ } } }); - {% endblock js_block %} diff --git a/common/templates/list.html b/common/templates/list.html index 6e6d81bf..07321313 100644 --- a/common/templates/list.html +++ b/common/templates/list.html @@ -102,7 +102,7 @@ {{ forloop.counter }} {{ user.first_name }} - {{ user.username }} + {{ user.username }} {{ user.email }} {% if user.is_superuser %} ADMIN {% else %} {{user.role}} {% endif %} diff --git a/common/templates/user_detail.html b/common/templates/user_detail.html new file mode 100644 index 00000000..d3970442 --- /dev/null +++ b/common/templates/user_detail.html @@ -0,0 +1,609 @@ +{% extends 'base.html' %} +{% load staticfiles %} +{% block breadcrumb %} +{% load thumbnail %} + + +{% endblock breadcrumb %} +{% block content %} + +
+
+
+
+
+
+
+ Overview + + + +
+
+
+
+ {% if user_obj.first_name %} +
+
+ + +
+
+ {% endif %} + {% if user_obj.last_name %} +
+
+ + +
+
+ {% endif %} + {% if user_obj.email %} +
+
+ + +
+
+ {% endif %} + {% if user_obj.username %} +
+
+ + +
+
+ {% endif %} + {% if user_obj.role %} +
+
+ + +
+
+ {% endif %} +
+
+
+
+ +
+ {% if user_obj.profile_pic %} + {% thumbnail request.user.profile_pic "125x125" as im %} + + {% endthumbnail %} + {% else %} + + {% endif %} +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ Accounts +
+
+ + {% if accounts|length > 0 %} + + + + + + + + + {% endif %} + + {% for account in accounts %} + + + + + + + {% endfor %} + +
S.NoAccount NamePhoneEmail
{{ forloop.counter }}{{ account.name }}{{ account.phone }}{{ account.email }}
+
+ {% ifequal accounts|length 0 %} +
No Account Records Found
+ {% endifequal %} +
+
+
+
+
+
+
+
+
+
+
+
+ Contacts +
+
+ + {% if contacts|length > 0 %} + + + + + + + + + {% endif %} + + {% for contact in contacts %} + + + + + + + {% endfor %} + +
S.NoContact NamePhoneEmail
{{ forloop.counter }}{{ contact.first_name }} {{ contact.last_name }}{{ contact.phone }}{{ contact.email }}
+
+ {% ifequal contacts|length 0 %} +
No Contact Records Found
+ {% endifequal %} +
+
+
+
+
+
+
+
+
+
+
+
+ Opportunities +
+
+ + {% if opportunity_list|length > 0 %} + + + + + + + + + {% endif %} + + {% for opportunity in opportunity_list %} + + + + + + + {% endfor %} + +
S.NoNameStageProbability
{{ forloop.counter }}{{opportunity.name}}{{opportunity.stage}}{{opportunity.probability}} {% if opportunity.probability %} % {% endif %}
+
+ `{% ifequal contacts|length 0 %} +
No Opportunity Records Found
+ {% endifequal %} +
+
+
+
+
+
+
+
+
+
+
+
+ Cases +
+
+ + {% if cases|length > 0 %} + + + + + + + + + {% endif %} + + {% for case in cases %} + + + + + + + {% endfor %} + +
S.NoNameStatusPriority
{{ forloop.counter }}{{ case.name }}{{ case.status }}{{ case.priority }}
+
+ {% ifequal cases|length 0 %} +
No Case Records Found
+ {% endifequal %} +
+
+
+
+
+
+
+
+
+ +{% endblock content %} +{% block js_block %} + + +{% endblock js_block %} \ No newline at end of file diff --git a/common/views.py b/common/views.py index 06b232e7..b3adeb7f 100644 --- a/common/views.py +++ b/common/views.py @@ -12,6 +12,10 @@ from common.forms import UserForm, LoginForm, ChangePasswordForm, PasswordResetE from django.contrib.auth.views import PasswordResetView from django.urls import reverse_lazy from django.conf import settings +from opportunity.models import Opportunity +from cases.models import Case +from contacts.models import Contact +from accounts.models import Account from django.template.loader import render_to_string @@ -192,15 +196,17 @@ class CreateUserView(AdminRequiredMixin, CreateView): class UserDetailView(AdminRequiredMixin, DetailView): model = User context_object_name = "users" - template_name = "list.html" + template_name = "user_detail.html" def get_context_data(self, **kwargs): context = super(UserDetailView, self).get_context_data(**kwargs) - users_list = User.objects.all() + user_obj = self.object context.update({ - "users": users_list, "user_obj": self.object, - "active_users": users_list.filter(is_active=True), - "inactive_users": users_list.filter(is_active=False) + "user_obj": user_obj, + "opportunity_list": Opportunity.objects.filter(assigned_to=user_obj.id), + "contacts": Contact.objects.filter(assigned_to=user_obj.id), + "cases": Case.objects.filter(assigned_to=user_obj.id), + "accounts": Account.objects.filter(assigned_to=user_obj.id), }) return context diff --git a/static/css/main.scss b/static/css/main.scss index 8a73e66d..9d082442 100644 --- a/static/css/main.scss +++ b/static/css/main.scss @@ -491,6 +491,7 @@ $color_2: #000; font-size: 0.9rem; border: none; padding:6px; + text-align: center; } } } @@ -502,7 +503,6 @@ $color_2: #000; font-size: 0.9rem; font-weight: 500; padding:7px 5px; - text-align: left; @media(min-width: $large){ font-size:1rem; } @@ -712,7 +712,7 @@ $color_2: #000; } } -.error { +.error, .errors { color: red; }