Skip to content
Merged

Dev #95

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion StronaProjektyKol/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,4 @@
GOTENBERG_URL = os.environ.get('GOTENBERG_URL')

SECRET_KEY = os.environ.get('SECRET_KEY')
DEBUG = os.environ.get('DEBUG', False)
DEBUG = os.environ.get("DEBUG", 'False').lower() == 'true'
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
echo "Applying database migrations..."
python manage.py migrate --noinput
python manage.py collectstatic --noinput
python manage.py loaddata announcement grades groups notificationperiod studentclubs
python manage.py loaddata grades groups notificationperiod studentclubs
python manage.py setup_scheduled_tasks
python manage.py qcluster &

Expand Down
3 changes: 0 additions & 3 deletions papers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from .models import *


class AnnouncementAdmin(SummernoteModelAdmin):
summernote_fields = '__all__'


class MassEmailModel(models.Model):
Expand Down Expand Up @@ -105,4 +103,3 @@ def get_urls(self):
admin.site.register(MessageSeen)
admin.site.register(NotificationPeriod)
admin.site.register(MassEmailModel, MassEmailModelAdmin)
admin.site.register(Announcement, AnnouncementAdmin)
16 changes: 16 additions & 0 deletions papers/migrations/0007_delete_announcement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 3.1.14 on 2026-02-05 09:54

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('papers', '0006_auto_20260204_1141'),
]

operations = [
migrations.DeleteModel(
name='Announcement',
),
]
8 changes: 0 additions & 8 deletions papers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,6 @@ def __str__(self):
return f'[{self.author}] - {self.paper}'


class Announcement(models.Model):
text = models.TextField()
created_at = models.DateTimeField(default=timezone.now)

def __str__(self):
return textwrap.shorten(self.text, width=20)


class Message(models.Model):
author = models.ForeignKey(User, on_delete=models.CASCADE)
paper = models.ForeignKey(Paper, related_name='paper', default=None, on_delete=models.CASCADE)
Expand Down
2 changes: 1 addition & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<div class="container">
<span class="text-muted">
<a href="https://kod.prz.edu.pl">
&copy;2021 <img class="footer_logo" src="{% static 'images/logo_color.png' %}" />
&copy;2026 <img class="footer_logo" src="{% static 'images/logo_color.png' %}" />
</a>
</span>
</div>
Expand Down
10 changes: 9 additions & 1 deletion users/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
from .models import UserDetail
from .models import UserDetail, ContactInfo, Announcement
from django.contrib import admin
from django_summernote.admin import SummernoteModelAdmin


class AnnouncementAdmin(SummernoteModelAdmin):
summernote_fields = '__all__'


admin.site.register(UserDetail)
admin.site.register(ContactInfo)
admin.site.register(Announcement, AnnouncementAdmin)
28 changes: 28 additions & 0 deletions users/migrations/0002_contactinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.1.14 on 2026-02-04 19:53

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('users', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='ContactInfo',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=128)),
('email', models.EmailField(blank=True, max_length=254, null=True)),
('phone', models.CharField(blank=True, max_length=32, null=True)),
('created_at', models.DateTimeField(default=django.utils.timezone.now)),
],
options={
'verbose_name': 'Kontakt',
'verbose_name_plural': 'Kontakty',
},
),
]
26 changes: 26 additions & 0 deletions users/migrations/0003_announcement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 3.1.14 on 2026-02-05 09:54

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('users', '0002_contactinfo'),
]

operations = [
migrations.CreateModel(
name='Announcement',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text', models.TextField()),
('created_at', models.DateTimeField(default=django.utils.timezone.now)),
],
options={
'verbose_name': 'Ogłoszenie',
'verbose_name_plural': 'Ogłoszenia',
},
),
]
18 changes: 18 additions & 0 deletions users/migrations/0004_announcement_show_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.14 on 2026-02-05 10:09

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('users', '0003_announcement'),
]

operations = [
migrations.AddField(
model_name='announcement',
name='show_date',
field=models.BooleanField(default=False),
),
]
29 changes: 29 additions & 0 deletions users/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib.auth.models import User
from django.db import models
from django.utils import timezone
import textwrap


class UserDetail(models.Model):
Expand All @@ -10,3 +11,31 @@ class UserDetail(models.Model):

def __str__(self):
return f'{self.user.username} detail'


class ContactInfo(models.Model):
name = models.CharField(max_length=128)
email = models.EmailField(blank=True, null=True)
phone = models.CharField(max_length=32, blank=True, null=True)
created_at = models.DateTimeField(default=timezone.now)

def __str__(self):
return self.name

class Meta:
verbose_name = "Kontakt"
verbose_name_plural = "Kontakty"


class Announcement(models.Model):
text = models.TextField()
created_at = models.DateTimeField(default=timezone.now)
show_date = models.BooleanField(default=False)

def __str__(self):
return textwrap.shorten(self.text, width=20)

class Meta:
verbose_name = "Ogłoszenie"
verbose_name_plural = "Ogłoszenia"

48 changes: 23 additions & 25 deletions users/templates/users/contact.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
{% extends "base.html" %}

{% block content %}
<h1 class="mb-4">Kontakt</h1>
<hr class="my-3">

<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<div class="row">
<h1>Kontakt</h1>
</div>
</div>
<div class="col-md-3"></div>
</div>

<hr class="my-1">

<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<div class="row">
<p>Telefon: {{ admin_phone }}</p>
</div>
<div class="row">
<p>Email: {{ admin_mail }}</p>
</div>
</div>
<br>

{% endblock %}
{% if contacts %}
{% for contact in contacts %}
<div class="mb-4 pb-3 border-bottom">
<h5 class="mb-2">{{ contact.name }}</h5>
{% if contact.email %}
<p class="mb-1">
<strong>Email:</strong>
<a href="mailto:{{ contact.email }}">{{ contact.email }}</a>
</p>
{% endif %}
{% if contact.phone %}
<p class="mb-1">
<strong>Telefon:</strong> {{ contact.phone }}
</p>
{% endif %}
</div>
{% endfor %}
{% else %}
<div class="alert alert-info">Brak danych kontaktowych</div>
{% endif %}
{% endblock %}
20 changes: 15 additions & 5 deletions users/templates/users/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
{% extends 'base.html' %}

{% block content %}
<br>
<div class="container mx-1 my-1">
{{ announcement.text|safe }}
</div>
{% endblock %}

{% if announcements %}
{% for announcement in announcements %}
<div class="mb-4 pb-3 border-bottom">
{% if announcement.show_date %}
<div class="mb-2">
<span class="badge badge-info">{{ announcement.created_at|date:"d.m.Y H:i" }}</span>
</div>
{% endif %}
<div>{{ announcement.text|safe }}</div>
</div>
{% endfor %}
{% else %}
<div class="alert alert-info">Brak ogłoszeń</div>
{% endif %}
{% endblock %}
15 changes: 6 additions & 9 deletions users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
# for TemplateView classes
from django.views.generic import ListView, TemplateView
from StronaProjektyKol.settings import SITE_NAME, SITE_DOMAIN, SITE_ADMIN_MAIL, SITE_ADMIN_PHONE
from papers.models import Announcement, NotificationPeriod, Paper
from papers.models import NotificationPeriod, Paper
# forms
from .forms import UserLoginForm, UserPasswordChangeForm
from .forms import UserRegisterForm
from .models import UserDetail
from .models import UserDetail, ContactInfo, Announcement


class IndexView(ListView):
Expand All @@ -36,7 +36,7 @@ def get_context_data(self, **kwargs):
# Create any data and add it to the context
context['site_name'] = 'index'
context['site_title'] = f'Strona główna - {SITE_NAME}'
context['announcement'] = Announcement.objects.order_by("-created_at").first()
context['announcements'] = Announcement.objects.order_by("-created_at")[:5]
return context


Expand Down Expand Up @@ -99,17 +99,14 @@ def get(self, request, *args, **kwargs):



class ContactView(ListView):
template_name = 'users/index.html'
model = Announcement
class ContactView(TemplateView):
template_name = 'users/contact.html'

def get_context_data(self, **kwargs):
# Call the base implementation first to get the context
context = super().get_context_data(**kwargs)
# Create any data and add it to the context
context['site_name'] = 'contact'
context['site_title'] = f'Kontakt - {SITE_NAME}'
context['announcement'] = Announcement.objects.order_by('id')[1:2].first()
context['contacts'] = ContactInfo.objects.all()
return context


Expand Down