mirror of
https://github.com/DerTyp7/tealcode-django-python.git
synced 2025-10-30 04:47:09 +01:00
intitial
This commit is contained in:
31
TealCode/analytics/migrations/0002_auto_20211123_1415.py
Normal file
31
TealCode/analytics/migrations/0002_auto_20211123_1415.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# 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),
|
||||||
|
),
|
||||||
|
]
|
||||||
23
TealCode/analytics/migrations/0003_auto_20211123_1420.py
Normal file
23
TealCode/analytics/migrations/0003_auto_20211123_1420.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# 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,17 +1,35 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from main.models import Topic, Category
|
from main.models import Topic, Category
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class View(models.Model):
|
class View(models.Model):
|
||||||
ip = models.CharField(max_length=200)
|
ip = models.CharField(max_length=200)
|
||||||
date = models.DateTimeField(default=timezone.now)
|
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)
|
topic = models.ForeignKey(Topic, on_delete=models.CASCADE, blank=True, null=True)
|
||||||
category = models.ForeignKey(Category, on_delete=models.CASCADE, blank=True, null=True)
|
category = models.ForeignKey(Category, on_delete=models.CASCADE, blank=True, null=True)
|
||||||
admin = models.BooleanField(default=False)
|
custom_title = models.CharField(max_length=250, blank=True)
|
||||||
home = models.BooleanField(default=False)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.ip
|
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
|
||||||
|
|||||||
@@ -2,19 +2,4 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Analytics</h2>
|
<h2>Analytics</h2>
|
||||||
|
|
||||||
<div class="main-content-block">
|
|
||||||
<h5>Clicks Last 30 Days</h5>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="main-content-block">
|
|
||||||
<h5>Clicks In Total</h5>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="main-content-block">
|
|
||||||
<h5>Clicks From Coutries Last 30 Days</h5>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="main-content-block">
|
|
||||||
<h5>Clicks From Coutries In Total</h5>
|
|
||||||
</div>
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
@@ -4,7 +4,7 @@ from .models import Category, Topic, Rating
|
|||||||
from analytics.models import View
|
from analytics.models import View
|
||||||
|
|
||||||
def index(req):
|
def index(req):
|
||||||
view = View(ip=get_ip(req), home=True)
|
view = View(ip=get_ip(req), custom_title="index")
|
||||||
view.save()
|
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})
|
||||||
|
|||||||
Reference in New Issue
Block a user