Quellcode durchsuchen

New app dashboard added and shown all review in a list

Mohidul Islam vor 5 Jahren
Ursprung
Commit
e9c80619b4

+ 0 - 0
dashboard/__init__.py


+ 3 - 0
dashboard/admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 5 - 0
dashboard/apps.py

@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class DashboardConfig(AppConfig):
+    name = 'dashboard'

+ 0 - 0
dashboard/migrations/__init__.py


+ 3 - 0
dashboard/models.py

@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.

+ 84 - 0
dashboard/static/main.css

@@ -0,0 +1,84 @@
+body {
+  background: #fafafa;
+  color: #333333;
+  margin-top: 5rem;
+}
+
+h1, h2, h3, h4, h5, h6 {
+  color: #444444;
+}
+
+ul {
+  margin: 0;
+}
+
+.bg-steel {
+  background-color: #5f788a;
+}
+
+.site-header .navbar-nav .nav-link {
+  color: #cbd5db;
+}
+
+.site-header .navbar-nav .nav-link:hover {
+  color: #ffffff;
+}
+
+.site-header .navbar-nav .nav-link.active {
+  font-weight: 500;
+}
+
+.content-section {
+  background: #ffffff;
+  padding: 10px 20px;
+  border: 1px solid #dddddd;
+  border-radius: 3px;
+  margin-bottom: 20px;
+}
+
+.article-title {
+  color: #444444;
+}
+
+a.article-title:hover {
+  color: #428bca;
+  text-decoration: none;
+}
+
+.article-content {
+  white-space: pre-line;
+}
+
+.article-img {
+  height: 65px;
+  width: 65px;
+  margin-right: 16px;
+}
+
+.article-metadata {
+  padding-bottom: 1px;
+  margin-bottom: 4px;
+  border-bottom: 1px solid #e3e3e3
+}
+
+.article-metadata a:hover {
+  color: #333;
+  text-decoration: none;
+}
+
+.article-svg {
+  width: 25px;
+  height: 25px;
+  vertical-align: middle;
+}
+
+.account-img {
+  height: 125px;
+  width: 125px;
+  margin-right: 20px;
+  margin-bottom: 16px;
+}
+
+.account-heading {
+  font-size: 2.5rem;
+}

+ 12 - 0
dashboard/templates/_review.html

@@ -0,0 +1,12 @@
+<article class="media content-section">
+    <img class="rounded-circle article-img" src="{{ review.reviewer_photo }}">
+    <div class="media-body">
+        <div class="article-metadata">
+            <span class="mr-2">{{ review.reviewer_name }}</span>
+            <small class="text-muted">{{ review.update_time|date:"F d, Y" }}</small>
+            <span style="color: #a41515; float: right">{% for star in "x"|ljust:review.star_rating %} &#9733; {% endfor %}</span>
+        </div>
+        <p class="article-content">{{ review.comment }}</p>
+        <p class="article-content">Reply: {{ review.reply.replied_text }}</p>
+    </div>
+</article>

+ 63 - 0
dashboard/templates/base.html

@@ -0,0 +1,63 @@
+{% load static %}
+<!DOCTYPE html>
+<html>
+<head>
+    <!-- Required meta tags -->
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+
+    <!-- Bootstrap CSS -->
+    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
+
+    <link rel="stylesheet" type="text/css" href="{% static 'main.css' %}">
+
+</head>
+<body>
+    <header class="site-header">
+      <nav class="navbar navbar-expand-md navbar-dark bg-steel fixed-top">
+        <div class="container">
+          <a class="navbar-brand mr-4" href="#">ER-CARE Review</a>
+          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
+          <span class="navbar-toggler-icon"></span>
+          </button>
+          <div class="collapse navbar-collapse" id="navbarToggle">
+            <div class="navbar-nav mr-auto">
+              <a class="nav-item nav-link" href="#">Home</a>
+              <a class="nav-item nav-link" href="#">About</a>
+            </div>
+            <!-- Navbar Right Side -->
+            <div class="navbar-nav">
+                <a class="nav-item nav-link" href="#">New Post</a>
+                <a class="nav-item nav-link" href="#">Login</a>
+            </div>
+          </div>
+        </div>
+      </nav>
+    </header>
+    <main role="main" class="container">
+      <div class="row">
+        <div class="col-md-9">
+          {% block content %}{% endblock %}
+        </div>
+        <div class="col-md-3">
+          <div class="content-section" style="position: fixed">
+            <h3>ER Locations</h3>
+              <ul class="list-group">
+                <li class="list-group-item list-group-item-light">Location1</li>
+              </ul>
+          </div>
+        </div>
+      </div>
+    </main>
+    <nav class="navbar navbar-expand-md navbar-dark bg-steel fixed-bottom">
+      <div class="container">
+        <span class="navbar-brand">&copy;2020 SignatureCare. - Developed by Byte Trek Ltd. </span>
+      </div>
+    </nav>
+    <!-- Optional JavaScript -->
+    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
+    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
+    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
+</body>
+</html>

+ 31 - 0
dashboard/templates/review_list.html

@@ -0,0 +1,31 @@
+{% extends "base.html" %}
+{% block content %}
+    {% for review in reviews %}
+        {% include '_review.html' %}
+    {% endfor %}
+
+    <div class="mb-5" align="center">
+    {% if reviews.has_other_pages %}
+
+      {% if reviews.has_previous %}
+        <a class="btn btn-outline-info mb-4" href="?page=1">First</a>
+        <a class="btn btn-outline-info mb-4" href="?page={{ reviews.previous_page_number }}">Previous</a>
+      {% endif %}
+
+      {% for num in reviews.paginator.page_range %}
+        {% if reviews.number == num %}
+          <a class="btn btn-info mb-4" href="?page={{ num }}">{{ num }}</a>
+        {% elif num > reviews.number|add:'-3' and num < reviews.number|add:'3' %}
+          <a class="btn btn-outline-info mb-4" href="?page={{ num }}">{{ num }}</a>
+        {% endif %}
+      {% endfor %}
+
+      {% if reviews.has_next %}
+        <a class="btn btn-outline-info mb-4" href="?page={{ reviews.next_page_number }}">Next</a>
+        <a class="btn btn-outline-info mb-4" href="?page={{ reviews.paginator.num_pages }}">Last</a>
+      {% endif %}
+
+    {% endif %}
+    </div>
+
+{% endblock content %}

+ 3 - 0
dashboard/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 6 - 0
dashboard/urls.py

@@ -0,0 +1,6 @@
+from django.urls import path
+from .views import ReviewListView
+
+urlpatterns = [
+    path('list/<location_id>/',ReviewListView.as_view(), name= 'review-list'),
+]

+ 22 - 0
dashboard/views.py

@@ -0,0 +1,22 @@
+from django.shortcuts import render
+from django.views.generic.list import View
+from review.models import Review, Reply
+from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
+
+
+class ReviewListView(View):
+
+    def get(self, request, location_id, *args, **kwargs):
+        reviews = Review.objects.filter(location_id=location_id).order_by('-update_time')
+        page = request.GET.get('page', 1)
+        # context = {
+        #     'reviews': reviews
+        # }
+        paginator = Paginator(reviews, 50)
+        try:
+            reviews = paginator.page(page)
+        except PageNotAnInteger:
+            reviews = paginator.page(1)
+        except EmptyPage:
+            reviews = paginator.page(paginator.num_pages)
+        return render(request, 'review_list.html', {'reviews': reviews})

+ 1 - 0
review_automation/settings.py

@@ -25,6 +25,7 @@ INSTALLED_APPS = [
 
     'gauth.apps.GauthConfig',
     'review.apps.ReviewConfig',
+    'dashboard.apps.DashboardConfig',
 ]
 
 MIDDLEWARE = [

+ 6 - 2
review_automation/urls.py

@@ -1,7 +1,11 @@
+from django.conf import settings
 from django.contrib import admin
 from django.urls import path, include
+from django.conf.urls.static import static
 
 urlpatterns = [
     path('admin/', admin.site.urls),
-    path('', include('gauth.urls'))
-]
+    path('', include('gauth.urls')),
+    path('dashboard/', include('dashboard.urls')),
+]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
+