mirror of
https://github.com/DerTyp7/tealcode-django-python.git
synced 2025-10-29 12:32:09 +01:00
g
This commit is contained in:
@@ -41,8 +41,6 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'main.apps.MainConfig',
|
'main.apps.MainConfig',
|
||||||
'analytics.apps.AnalyticsConfig',
|
|
||||||
'ipware',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ from django.views.generic.base import TemplateView
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', include('main.urls')),
|
path('', include('main.urls')),
|
||||||
path('analytics/', include('analytics.urls')),
|
|
||||||
path("robots.txt", TemplateView.as_view(template_name="robots.txt", content_type="text/plain")),
|
path("robots.txt", TemplateView.as_view(template_name="robots.txt", content_type="text/plain")),
|
||||||
path('AD/SDGFOLKJASDNVASDFASDFSLAKDF/', admin.site.urls),
|
path('AD/SDGFOLKJASDNVASDFASDFSLAKDF/', admin.site.urls),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
from analytics.models import View
|
|
||||||
|
|
||||||
admin.site.register(View)
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class AnalyticsConfig(AppConfig):
|
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
|
||||||
name = 'analytics'
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
# Generated by Django 3.2.9 on 2021-11-22 18:23
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
import django.utils.timezone
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
initial = True
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('main', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='View',
|
|
||||||
fields=[
|
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('ip', models.CharField(max_length=200)),
|
|
||||||
('date', models.DateTimeField(default=django.utils.timezone.now)),
|
|
||||||
('admin', models.BooleanField(default=False)),
|
|
||||||
('home', models.BooleanField(default=False)),
|
|
||||||
('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='main.category')),
|
|
||||||
('topic', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='main.topic')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
# Generated by Django 3.2.9 on 2021-11-23 13:15
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('analytics', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='view',
|
|
||||||
name='admin',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='view',
|
|
||||||
name='home',
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='view',
|
|
||||||
name='country',
|
|
||||||
field=models.CharField(blank=True, max_length=250),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='view',
|
|
||||||
name='custom_title',
|
|
||||||
field=models.CharField(blank=True, max_length=250),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
# Generated by Django 3.2.9 on 2021-11-23 13:20
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('analytics', '0002_auto_20211123_1415'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='view',
|
|
||||||
name='city',
|
|
||||||
field=models.CharField(blank=True, max_length=250),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='view',
|
|
||||||
name='state',
|
|
||||||
field=models.CharField(blank=True, max_length=250),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
from django.utils import timezone
|
|
||||||
from main.models import Topic, Category
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class View(models.Model):
|
|
||||||
ip = models.CharField(max_length=200)
|
|
||||||
date = models.DateTimeField(default=timezone.now)
|
|
||||||
country = models.CharField(max_length=250, blank=True)
|
|
||||||
state = models.CharField(max_length=250, blank=True)
|
|
||||||
city = models.CharField(max_length=250, blank=True)
|
|
||||||
topic = models.ForeignKey(Topic, on_delete=models.CASCADE, blank=True, null=True)
|
|
||||||
category = models.ForeignKey(Category, on_delete=models.CASCADE, blank=True, null=True)
|
|
||||||
custom_title = models.CharField(max_length=250, blank=True)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
a = self.ip
|
|
||||||
|
|
||||||
if self.country:
|
|
||||||
a = a + " - " + self.country
|
|
||||||
|
|
||||||
if self.topic:
|
|
||||||
a = a + " - " + self.topic.title
|
|
||||||
|
|
||||||
if self.category:
|
|
||||||
a = a + " - " + self.category.title
|
|
||||||
|
|
||||||
if self.custom_title:
|
|
||||||
a = a + " - " + self.custom_title
|
|
||||||
|
|
||||||
a = a + " - " + str(self.date.day) + "." + str(self.date.month) + "." + str(self.date.year)
|
|
||||||
return a
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{% extends "base.html" %}
|
|
||||||
{% block content %}
|
|
||||||
<h2>Analytics</h2>
|
|
||||||
|
|
||||||
{% endblock content %}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
from django.urls import path
|
|
||||||
from . import views
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
path('', views.index, name="analytics-index"),
|
|
||||||
]
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
from django.shortcuts import render
|
|
||||||
from django.contrib.auth.decorators import login_required
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
def index(req):
|
|
||||||
return render(req, 'analytics/index.html')
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 3.2.9 on 2021-11-22 18:23
|
# Generated by Django 3.2.9 on 2021-11-23 17:55
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
|||||||
@@ -4,14 +4,9 @@
|
|||||||
<head>
|
<head>
|
||||||
<!-- Google Analytics -->
|
<!-- Google Analytics -->
|
||||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-PGM5LTFSMG"></script>
|
<script async src="https://www.googletagmanager.com/gtag/js?id=G-PGM5LTFSMG"></script>
|
||||||
<script>
|
<script>window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;ga('create', 'UA-213552250-1', {'storage': 'none',});ga('send', 'pageview');</script>
|
||||||
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
|
|
||||||
ga('create', 'UA-213552250-1', {
|
|
||||||
'storage': 'none',
|
|
||||||
});
|
|
||||||
ga('send', 'pageview');
|
|
||||||
</script>
|
|
||||||
<script async src='https://www.google-analytics.com/analytics.js'></script>
|
<script async src='https://www.google-analytics.com/analytics.js'></script>
|
||||||
|
<script src="{% static 'js/cookies.js' %}"></script>
|
||||||
<!-- End Google Analytics -->
|
<!-- End Google Analytics -->
|
||||||
|
|
||||||
<!-- Required META Tags-->
|
<!-- Required META Tags-->
|
||||||
@@ -38,7 +33,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-dark">
|
<body class="bg-dark">
|
||||||
<script src="{% static 'js/cookies.js' %}"></script>
|
|
||||||
|
|
||||||
|
|
||||||
<header class="p-3 bg-dark text-white shadow">
|
<header class="p-3 bg-dark text-white shadow">
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
from django.http.response import HttpResponse, HttpResponseForbidden
|
from django.http.response import HttpResponse
|
||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
from .models import Category, Topic, Rating
|
from .models import Category, Topic, Rating
|
||||||
from analytics.models import View
|
|
||||||
|
|
||||||
def index(req):
|
def index(req):
|
||||||
view = View(ip=get_ip(req), custom_title="index")
|
|
||||||
view.save()
|
|
||||||
categorys_obj = Category.objects.all()
|
categorys_obj = Category.objects.all()
|
||||||
return render(req, "main/index.html", {'categorys': categorys_obj})
|
return render(req, "main/index.html", {'categorys': categorys_obj})
|
||||||
|
|
||||||
@@ -40,10 +37,6 @@ def topic(req, category, topic):
|
|||||||
'notHelpful_count': notHelpful_count,
|
'notHelpful_count': notHelpful_count,
|
||||||
'read_more': topic_obj.read_more,
|
'read_more': topic_obj.read_more,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
view = View(ip=get_ip(req), topic=topic_obj)
|
|
||||||
view.save()
|
|
||||||
return render(req, "main/topic.html", context)
|
return render(req, "main/topic.html", context)
|
||||||
|
|
||||||
return redirect("main-index")
|
return redirect("main-index")
|
||||||
@@ -57,9 +50,6 @@ def category(req, category):
|
|||||||
if category_obj:
|
if category_obj:
|
||||||
topics_obj = Topic.objects.filter(category=category_obj)
|
topics_obj = Topic.objects.filter(category=category_obj)
|
||||||
|
|
||||||
view = View(ip=get_ip(req), category=category_obj)
|
|
||||||
view.save()
|
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'category_obj': category_obj,
|
'category_obj': category_obj,
|
||||||
'topics': topics_obj,
|
'topics': topics_obj,
|
||||||
@@ -83,8 +73,6 @@ def search(req, value): # https://django-taggit.readthedocs.io/en/latest/getting
|
|||||||
def sitemap(req):
|
def sitemap(req):
|
||||||
topics = Topic.objects.all()
|
topics = Topic.objects.all()
|
||||||
categories = Category.objects.all()
|
categories = Category.objects.all()
|
||||||
#REPLACE ALL BLANKS WITH %20
|
|
||||||
|
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'topics': topics,
|
'topics': topics,
|
||||||
|
|||||||
Reference in New Issue
Block a user