test bug ip save

This commit is contained in:
Parsa Nazer
2025-02-21 01:38:49 +03:30
parent 258b72bafc
commit 4109d44694
3 changed files with 21 additions and 1 deletions
@@ -0,0 +1,18 @@
# Generated by Django 5.1.2 on 2025-02-20 22:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('account', '0018_alter_securitybreachattemptmodel_created_at_and_more'),
]
operations = [
migrations.AlterField(
model_name='securitybreachattemptmodel',
name='ip',
field=models.CharField(max_length=100, unique=True, verbose_name='آدرس آی\u200cپی'),
),
]
+1 -1
View File
@@ -217,7 +217,7 @@ def get_location_from_ip(ip_address):
return None
class SecurityBreachAttemptModel(models.Model):
ip = models.CharField(max_length=40, unique=True, verbose_name="آدرس آی‌پی")
ip = models.CharField(max_length=100, unique=True, verbose_name="آدرس آی‌پی")
country = models.CharField(max_length=40, verbose_name="کشور", blank=True, null=True)
region_name = models.CharField(max_length=40, verbose_name="منطقه", blank=True, null=True)
city = models.CharField(max_length=40, verbose_name="شهر", blank=True, null=True)
+2
View File
@@ -272,6 +272,7 @@ class FakeAdminLoginView(View):
ip = x_forwarded_for.split(',')[0]
else:
ip = request.META.get("REMOTE_ADDR")
print(ip)
hacker, created = SecurityBreachAttemptModel.objects.get_or_create(ip=ip)
return render(request, 'admin/fake_login.html', self.get_context(request))
@@ -281,6 +282,7 @@ class FakeAdminLoginView(View):
ip = x_forwarded_for.split(',')[0]
else:
ip = request.META.get("REMOTE_ADDR")
print(ip)
hacker, created = SecurityBreachAttemptModel.objects.get_or_create(ip=ip)
hacker.trys += 1
hacker.save()