diff --git a/ddcz/migrations/0011_dating_autopublish_20250116_2222.py b/ddcz/migrations/0011_dating_autopublish_20250116_2222.py
new file mode 100644
index 0000000..cec423e
--- /dev/null
+++ b/ddcz/migrations/0011_dating_autopublish_20250116_2222.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.1.14 on 2025-01-16 21:22
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ddcz', '0010_dating_20241230_1327'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='dating',
+ name='published',
+ field=models.DateTimeField(auto_now_add=True, db_column='datum', null=True, verbose_name='Datum'),
+ ),
+ ]
diff --git a/ddcz/models/used/social.py b/ddcz/models/used/social.py
index c2a97b6..3490a09 100644
--- a/ddcz/models/used/social.py
+++ b/ddcz/models/used/social.py
@@ -51,7 +51,11 @@ class Dating(models.Model):
verbose_name="Doba hraní DrD",
)
published = models.DateTimeField(
- blank=True, null=True, db_column="datum", verbose_name="Datum"
+ blank=True,
+ null=True,
+ db_column="datum",
+ verbose_name="Datum",
+ auto_now_add=True,
)
text = MisencodedTextField(db_column="text")
group = MisencodedCharField(
diff --git a/ddcz/templates/base/light-dark/left_menu.html b/ddcz/templates/base/light-dark/left_menu.html
index 0dc0818..edae3c4 100644
--- a/ddcz/templates/base/light-dark/left_menu.html
+++ b/ddcz/templates/base/light-dark/left_menu.html
@@ -93,7 +93,7 @@
Kontakt
diff --git a/ddcz/tests/test_ui/cases.py b/ddcz/tests/test_ui/cases.py
index 220f832..90a6288 100644
--- a/ddcz/tests/test_ui/cases.py
+++ b/ddcz/tests/test_ui/cases.py
@@ -30,6 +30,7 @@ class MainPage(Enum):
NAVIGATION_TAVERN = '//*[@id="ddcz_nav_tavern"]'
NAVIGATION_PHORUM = '//*[@id="ddcz_nav_phorum"]'
NAVIGATION_MARKET = '//*[@id="ddcz_nav_market"]'
+ NAVIGATION_DATING = '//*[@id="ddcz_nav_dating"]'
class SeleniumTestCase(StaticLiveServerTestCase):
diff --git a/ddcz/tests/test_ui/pages_dating.py b/ddcz/tests/test_ui/pages_dating.py
new file mode 100644
index 0000000..a6255dd
--- /dev/null
+++ b/ddcz/tests/test_ui/pages_dating.py
@@ -0,0 +1,24 @@
+from enum import Enum
+
+
+class DatingListPage(Enum):
+ """Selectors for the dating list page"""
+
+ FIRST_TEXT = "//article[@class='dating'][1]//span[@class='label'][text()='Text:']/following-sibling::span[@class='value']"
+ CREATE_DATING_LINK = "//a[contains(@href, 'seznamka/pridat')]"
+ NAVIGATION_DATING = "//a[contains(@href, 'seznamka')]"
+
+
+class DatingCreatePage(Enum):
+ """Selectors for the dating creation page"""
+
+ NAME_INPUT = "id_name"
+ EMAIL_INPUT = "id_email"
+ AREA_INPUT = "id_area"
+ TEXT_INPUT = "id_text"
+ GROUP_SELECT = "id_group"
+ AGE_INPUT = "id_age"
+ PHONE_INPUT = "id_phone"
+ MOBILE_INPUT = "id_mobil"
+ EXPERIENCE_INPUT = "id_experience"
+ SUBMIT_BUTTON = "//button[@type='submit']"
diff --git a/ddcz/tests/test_ui/test_dating.py b/ddcz/tests/test_ui/test_dating.py
new file mode 100644
index 0000000..95a3dff
--- /dev/null
+++ b/ddcz/tests/test_ui/test_dating.py
@@ -0,0 +1,108 @@
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support.select import Select
+
+from .cases import SeleniumTestCase, MainPage
+from ..model_generator import get_alphabetic_user_profiles
+from .pages_dating import DatingListPage, DatingCreatePage
+from ddcz.models import Dating
+from ddcz.geo import CZECHOSLOVAK_REGIONS
+
+
+class TestDating(SeleniumTestCase):
+ reset_sequences = True
+
+ def setUp(self):
+ super().setUp()
+ self.user = get_alphabetic_user_profiles(
+ number_of_users=1, saved=True, with_corresponding_user=True
+ )[0]
+ self.existing_dating_entry = Dating.objects.create(
+ user_profile=self.user,
+ name="Test User",
+ area=CZECHOSLOVAK_REGIONS[1][1],
+ text="Zahrál bych si",
+ email="test@example.com",
+ )
+ self.selenium.get(self.live_server_url)
+
+ def navigate_to_dating(self, user_profile=None):
+ if user_profile:
+ return self.navigate_as_authenticated_user(
+ user_profile,
+ navigation_element=MainPage.NAVIGATION_DATING,
+ expected_title="Seznamka",
+ )
+ else:
+ self.selenium.find_element(
+ By.XPATH, MainPage.NAVIGATION_DATING.value
+ ).click()
+
+ def navigate_to_dating_create(self, user_profile=None):
+ self.navigate_to_dating(user_profile)
+ self.selenium.find_element(
+ By.XPATH, DatingListPage.CREATE_DATING_LINK.value
+ ).click()
+
+ def create_dating_entry(
+ self,
+ name,
+ area,
+ text,
+ email=None,
+ group=None,
+ age=None,
+ phone=None,
+ mobile=None,
+ experience=None,
+ ):
+ """Helper method to fill and submit dating entry form"""
+ self.selenium.find_element(By.ID, DatingCreatePage.NAME_INPUT.value).send_keys(
+ name
+ )
+ if email:
+ self.selenium.find_element(
+ By.ID, DatingCreatePage.EMAIL_INPUT.value
+ ).send_keys(email)
+ self.selenium.find_element(By.ID, DatingCreatePage.AREA_INPUT.value).send_keys(
+ area
+ )
+ self.selenium.find_element(By.ID, DatingCreatePage.TEXT_INPUT.value).send_keys(
+ text
+ )
+
+ if group:
+ select = Select(
+ self.selenium.find_element(By.ID, DatingCreatePage.GROUP_SELECT.value)
+ )
+ select.select_by_visible_text(group)
+ if age:
+ self.selenium.find_element(
+ By.ID, DatingCreatePage.AGE_INPUT.value
+ ).send_keys(age)
+ if phone:
+ self.selenium.find_element(
+ By.ID, DatingCreatePage.PHONE_INPUT.value
+ ).send_keys(phone)
+ if mobile:
+ self.selenium.find_element(
+ By.ID, DatingCreatePage.MOBILE_INPUT.value
+ ).send_keys(mobile)
+ if experience:
+ self.selenium.find_element(
+ By.ID, DatingCreatePage.EXPERIENCE_INPUT.value
+ ).send_keys(experience)
+
+ self.selenium.find_element(
+ By.XPATH, DatingCreatePage.SUBMIT_BUTTON.value
+ ).click()
+
+ def test_can_view_dating_list_anonymous(self):
+ """Test that anonymous user can view dating list"""
+ self.navigate_to_dating()
+ text = self.selenium.find_element(By.XPATH, '//h1[@class="page-heading"]').text
+ self.assertEquals("Seznamka", text)
+
+ text = self.selenium.find_element(
+ By.XPATH, DatingListPage.FIRST_TEXT.value
+ ).text
+ self.assertEquals(self.existing_dating_entry.text, text)