diff --git a/app/models.py b/app/models.py index f50c904311702c26984f43b30fde58c3ee278f57..46141491f5a40c4b187d485404e7c1e7959e5bd7 100644 --- a/app/models.py +++ b/app/models.py @@ -208,7 +208,6 @@ class ViewStatistics(models.Model): materi = models.ForeignKey(Materi, models.SET_NULL, null=True, related_name="baca") timestamp = models.DateTimeField(default=timezone.now) - class DownloadStatistics(models.Model): materi = models.ForeignKey(Materi, models.SET_NULL, null=True, related_name="unduh") downloader = models.ForeignKey(User, models.SET_NULL, blank=True, null=True, related_name="riwayat_unduh") diff --git a/app/services.py b/app/services.py index ab9d56301e62f2fd921bed9e76d4bf0a8c8aea0d..a563bc164ba69d22b600489c246de602f89f23fb 100644 --- a/app/services.py +++ b/app/services.py @@ -156,6 +156,10 @@ class DetailMateriService: def init_materi_download_count(context, materi): context["materi_download_count"] = materi.unduh.all().count() + @staticmethod + def init_materi_view_count(context, materi): + context["materi_view_count"] = materi.baca.all().count() + class CitationService: @staticmethod diff --git a/app/templates/app/detail_materi.html b/app/templates/app/detail_materi.html index 278c5decd9fd975e8bdac221ee5b7f70777737fa..ed1af6476fca69804234964d415e76c1aa914231 100644 --- a/app/templates/app/detail_materi.html +++ b/app/templates/app/detail_materi.html @@ -172,6 +172,14 @@ div.review {

{{materi_download_count}}

+
+
+
Telah dilihat
+
+
+

{{materi_view_count}}

+
+