Add translated strings
This commit is contained in:
parent
db85a5f20a
commit
799f0be53e
21 changed files with 131 additions and 124 deletions
|
@ -2,6 +2,7 @@ from django import forms
|
|||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django.utils.safestring import mark_safe
|
||||
from friendly_captcha.fields import FrcCaptchaField
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from .models import Offer, PflaenzliUser, Wish
|
||||
|
||||
|
@ -22,11 +23,11 @@ class RegistrationForm(UserCreationForm):
|
|||
|
||||
class FilterForm(forms.Form):
|
||||
text = forms.CharField(max_length=128, required=False, label=mark_safe(
|
||||
'<i class="fa-solid fa-magnifying-glass"></i> Search'))
|
||||
f'<i class="fa-solid fa-magnifying-glass"></i> {_("Search")}'))
|
||||
zipcode = forms.CharField(max_length=4, required=False, label=mark_safe(
|
||||
'<i class="fa-solid fa-location-dot"></i> Zipcode'))
|
||||
f'<i class="fa-solid fa-location-dot"></i> {_("ZIP code")}'))
|
||||
distance = forms.IntegerField(required=False, label=mark_safe(
|
||||
'<i class="fa-solid fa-signs-post"></i> Distance (km)'))
|
||||
f'<i class="fa-solid fa-signs-post"></i> {_("Entfernung")} (km)'))
|
||||
|
||||
|
||||
class WishForm(forms.ModelForm):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from django.core.mail import EmailMessage, EmailMultiAlternatives
|
||||
from django.urls import reverse
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
def send_offer_email(request, offer, sender_user, recipient_user):
|
||||
|
@ -9,7 +10,7 @@ def send_offer_email(request, offer, sender_user, recipient_user):
|
|||
plain_text = get_offer_text(request, offer, sender_user, recipient_user)
|
||||
|
||||
message = EmailMultiAlternatives(
|
||||
f'{sender_user.username} wants to trade',
|
||||
f'{sender_user.username} {_("wants to trade")}',
|
||||
plain_text,
|
||||
'no-reply@pflaenz.li',
|
||||
[recipient_user.email],
|
||||
|
@ -22,4 +23,4 @@ def send_offer_email(request, offer, sender_user, recipient_user):
|
|||
|
||||
|
||||
def get_offer_text(request, offer, sender_user, recipient_user):
|
||||
return f"Hello {recipient_user.username},\n\nThe user {sender_user.username} would like to trade '{offer.title}' with you!\n\nIf you would like to trade with {sender_user.username}, just reply to this email to get in touch with them.\n\nYou can also view their offers here: {request.scheme}://{request.get_host()}{reverse('user_detail', args=[sender_user.id])}"
|
||||
return f"{_('Hello')} {recipient_user.username},\n\n{sender_user.username} {_('is interested in')} {offer.title}!\n\n{_('Checkout their offers')}: {request.scheme}://{request.get_host()}{reverse('user_detail', args=[sender_user.id])}\n\n{_('Contact')} {sender_user.username}, {_('by replying to this mail')}."
|
||||
|
|
|
@ -5,26 +5,27 @@ from django.dispatch import receiver
|
|||
from django.contrib.auth.models import AbstractUser
|
||||
from django.utils import timezone
|
||||
from django.core.files.storage import default_storage
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class PflaenzliUser(AbstractUser):
|
||||
email = models.EmailField(max_length=254)
|
||||
zipcode = models.PositiveIntegerField(blank=True, null=True)
|
||||
zipcode = models.PositiveIntegerField(blank=True, null=True, verbose_name=_('ZIP Code'))
|
||||
|
||||
|
||||
class Offer(models.Model):
|
||||
created = models.DateTimeField(default=timezone.now)
|
||||
user = models.ForeignKey(PflaenzliUser, on_delete=models.CASCADE)
|
||||
title = models.CharField(max_length=50)
|
||||
description = models.TextField(max_length=5000)
|
||||
zipcode = models.IntegerField(blank=True, default=0)
|
||||
image = models.ImageField(upload_to="uploads/")
|
||||
title = models.CharField(max_length=50, verbose_name=_('Title'))
|
||||
description = models.TextField(max_length=5000, verbose_name=_('Description'))
|
||||
zipcode = models.IntegerField(blank=True, default=0, verbose_name=_('ZIP Code'))
|
||||
image = models.ImageField(upload_to="uploads/", verbose_name=_('Image'))
|
||||
|
||||
|
||||
class Wish(models.Model):
|
||||
created = models.DateTimeField(default=timezone.now)
|
||||
user = models.ForeignKey(PflaenzliUser, on_delete=models.CASCADE)
|
||||
title = models.CharField(max_length=200)
|
||||
title = models.CharField(max_length=200, verbose_name=_('Title'))
|
||||
|
||||
|
||||
@receiver(models.signals.post_delete, sender=Offer)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% block title %}Home{% endblock %}
|
||||
{% block meta %}<meta name="description" content="A platform to trade plants.">{% endblock %}
|
||||
{% block background %}home-background{% endblock %}
|
||||
|
@ -9,18 +10,18 @@
|
|||
<div class="home-background"></div>
|
||||
<div class="pfl-home-logo xl-align-self-center col-lg h-100 mb-3"></div>
|
||||
<div class="col-lg">
|
||||
<h1 class="display-5 fw-bold">Welcome to Pflänz.li</h1>
|
||||
<h1 class="display-5 fw-bold">{% trans "Welcome to Pflänz.li" %}</h1>
|
||||
<p class="fs-4">
|
||||
This is a platform to trade plants. You can offer plants and setup a wishlist what you want to trade it for.
|
||||
{% trans "This is a platform to trade plants. You can offer plants and setup a wishlist what you want to trade it for." %}
|
||||
</p>
|
||||
<hr />
|
||||
<p>To offer your plants, please register first.</p>
|
||||
<p>{% trans "To offer your plants, please register first." %}</p>
|
||||
<a href="{% url 'list_offers' %}"
|
||||
class="btn btn-pfl btn-lg mb-3"
|
||||
type="button">Show Offers</a>
|
||||
type="button">{% trans "Offers" %}</a>
|
||||
<a href="{% url 'register_user' %}"
|
||||
class="btn btn-secondary btn-lg mb-3"
|
||||
type="button">Register</a>
|
||||
type="button">{% trans "Register" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% load static %}
|
||||
{% load i18n %}
|
||||
<!doctype html>
|
||||
<html lang="en" class="h-100">
|
||||
<head>
|
||||
|
@ -6,12 +7,6 @@
|
|||
{% block title %}{% endblock %}
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!--
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="{% static 'favicons/favicon-32x32.png' %}">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="{% static 'favicons/favicon-16x16.png' %}">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="{% static 'favicons/apple-touch-icon.' %}png">
|
||||
<link rel="manifest" href="{% static 'favicons/manifest.json' %}">
|
||||
-->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css"
|
||||
rel="stylesheet"
|
||||
integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD"
|
||||
|
@ -44,6 +39,10 @@
|
|||
sizes="16x16"
|
||||
href="{% static 'favicon/favicon-16x16.png' %}">
|
||||
<link rel="manifest" href="{% static 'favicon/site.webmanifest' %}">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN"
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="{% static 'bootstrap-color-toggler.js' %}"></script>
|
||||
{% block head %}{% endblock %}
|
||||
</head>
|
||||
<body class="d-flex flex-column h-100 justify-content-between {% block background %}{% endblock background %}">
|
||||
|
@ -61,17 +60,17 @@
|
|||
data-bs-target="#navbarSupportedContent"
|
||||
aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false"
|
||||
aria-label="Toggle navigation">
|
||||
aria-label="{% trans 'Toggle navigation' %}%">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse justify-content-between"
|
||||
id="navbarSupportedContent">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'list_offers' %}"><i class="fa-solid fa-seedling"></i><span class="ms-2">Offers</span></a>
|
||||
<a class="nav-link" href="{% url 'list_offers' %}"><i class="fa-solid fa-seedling"></i><span class="ms-2">{% trans "Offers" %}</span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'create_offer' %}"><i class="fa-solid fa-square-plus"></i><span class="ms-2">New Offer</span></a>
|
||||
<a class="nav-link" href="{% url 'create_offer' %}"><i class="fa-solid fa-square-plus"></i><span class="ms-2">{% trans "New Offer" %}</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="navbar-nav mr-auto">
|
||||
|
@ -82,7 +81,7 @@
|
|||
aria-expanded="false"
|
||||
data-bs-toggle="dropdown"
|
||||
data-bs-display="static">
|
||||
<i class="fa-solid fa-circle-half-stroke"></i><span class="d-lg-none ms-2">Change theme</span>
|
||||
<i class="fa-solid fa-circle-half-stroke"></i><span class="d-lg-none ms-2">{% trans "Change theme" %}</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end"
|
||||
aria-labelledby="bd-theme"
|
||||
|
@ -91,14 +90,14 @@
|
|||
<button type="button"
|
||||
class="dropdown-item d-flex align-items-center"
|
||||
data-bs-theme-value="light">
|
||||
<i class="fa-solid fa-sun"></i><span class="ms-2">Light</span>
|
||||
<i class="fa-solid fa-sun"></i><span class="ms-2">{% trans "Light" %}</span>
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button type="button"
|
||||
class="dropdown-item d-flex align-items-center"
|
||||
data-bs-theme-value="dark">
|
||||
<i class="fa-solid fa-moon"></i><span class="ms-2">Dark</span>
|
||||
<i class="fa-solid fa-moon"></i><span class="ms-2">{% trans "Dark" %}</span>
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
|
@ -128,7 +127,7 @@
|
|||
</a>
|
||||
</li>
|
||||
<li class="dropdown-item">
|
||||
<a class="nav-link" href="{% url 'wishlist' user.id %}"><i class="fa-solid fa-star"></i><span class="ms-2">Wishlist</span></a>
|
||||
<a class="nav-link" href="{% url 'wishlist' user.id %}"><i class="fa-solid fa-star"></i><span class="ms-2">{% trans "Wishlist" %}</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -179,15 +178,11 @@
|
|||
<a href="{% url 'faq' %}">FAQ</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'imprint' %}">Imprint</a>
|
||||
<a href="{% url 'imprint' %}">{% trans "Imprint" %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN"
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="{% static 'bootstrap-color-toggler.js' %}"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}Offer: {{ offer.title }}{% endblock %}
|
||||
{% block meta %}
|
||||
<meta name="description"
|
||||
|
@ -6,7 +7,9 @@
|
|||
<meta name="author" content="{{ offer.user.username }}">
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
{% if offer.user == request.user %}<div class="alert alert-info" role="alert">This is your offer!</div>{% endif %}
|
||||
{% if offer.user == request.user %}
|
||||
<div class="alert alert-info" role="alert">{% trans "This is your offer!" %}</div>
|
||||
{% endif %}
|
||||
<div class="show-offer-container row gx-5">
|
||||
<div class="show-img-container col-12 col-md-6">
|
||||
<img class="mb-3 img-fluid rounded"
|
||||
|
@ -19,7 +22,7 @@
|
|||
<p class="mr-3">
|
||||
<i class="fas fa-user"></i>
|
||||
{% if offer.user == user %}
|
||||
Me
|
||||
{% trans "You" %}
|
||||
{% else %}
|
||||
{{ offer.user.username }}
|
||||
{% endif %}
|
||||
|
@ -33,7 +36,7 @@
|
|||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<h3>Description</h3>
|
||||
<h3>{% trans "Description" %}</h3>
|
||||
<p>{{ offer.description }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -55,34 +58,34 @@
|
|||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" id="exampleModalLabel">Delete offer</h1>
|
||||
<h1 class="modal-title fs-5" id="exampleModalLabel">{% trans "Delete offer" %}</h1>
|
||||
<button type="button"
|
||||
class="btn-close"
|
||||
data-bs-dismiss="modal"
|
||||
aria-label="Close"></button>
|
||||
aria-label="{% trans 'Close' %}"></button>
|
||||
</div>
|
||||
<div class="modal-body">Do you really want to delete this offer? This can't be undone.</div>
|
||||
<div class="modal-body">{% trans "Do you really want to delete this offer? This can't be undone." %}</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
|
||||
<a href="{% url 'offer_delete' offer.id %}"
|
||||
type="button"
|
||||
class="btn btn-danger">Delete</a>
|
||||
class="btn btn-danger">{% trans "Delete" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<h3>Wishes</h3>
|
||||
<p>{{ offer.user.username }} would like some of the following in return:</p>
|
||||
<h3>{% trans "Wishes" %}</h3>
|
||||
<p>{{ offer.user.username }} {% trans "would like some of the following in return" %}:</p>
|
||||
<div class="mb-3">
|
||||
{% if wishes %}
|
||||
<ul class="list-group">
|
||||
{% for wish in wishes %}<li class="list-group-item">{{ wish.title }}</li>{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<div class="alert alert-warning" role="alert">There are currently no wishes!</div>
|
||||
<div class="alert alert-warning" role="alert">{% trans "There are currently no wishes!" %}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<a class="btn btn-pfl mb-3" href="{% url 'offer_trade' offer.id %}">Offer trade</a>
|
||||
<a class="btn btn-pfl mb-3" href="{% url 'offer_trade' offer.id %}">{% trans "Offer trade" %}</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
{% block title %}Edit offer{% endblock %}
|
||||
{% block content %}
|
||||
{% for message in app.flashes('error') %}
|
||||
<div class="alert alert-error" role="alert">{{ message }}</div>
|
||||
{% endfor %}
|
||||
<h1 class="mb-3">Edit offer</h1>
|
||||
{{ form_start(offer_form) }}
|
||||
{{ form_row(offer_form.title) }}
|
||||
{{ form_row(offer_form.zipCode) }}
|
||||
{{ form_row(offer_form.description) }}
|
||||
{{ form_row(offer_form.photo, {
|
||||
label: 'Choose file'
|
||||
}) }}
|
||||
{{ form_end(offer_form) }}
|
||||
{% endblock %}
|
|
@ -1,17 +1,20 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load crispy_forms_tags %}
|
||||
{% block title %}Offers{% endblock %}
|
||||
{% block title %}
|
||||
{% trans 'Filter' %}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<h1 class="mt-3">
|
||||
Offers
|
||||
{% trans 'Filter' %}
|
||||
<button class="btn btn-pfl"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#filterCollapse"
|
||||
aria-expanded="true"
|
||||
aria-controls="filterCollapse">
|
||||
<i class="fa-solid fa-filter"></i> Filter
|
||||
<i class="fa-solid fa-filter"></i> {% trans 'Filter' %}
|
||||
</button>
|
||||
</h1>
|
||||
<form method="post"
|
||||
|
@ -20,7 +23,7 @@
|
|||
id="filterCollapse">
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
<button type="submit" class="btn btn-pfl">Filter</button>
|
||||
<button type="submit" class="btn btn-pfl">{% trans 'Filter' %}</button>
|
||||
</form>
|
||||
{% if offers %}
|
||||
<div class="row row-cols-1 row-cols-md-2 row-cols-xl-3 mt-3 mb-3 row-gap-5">
|
||||
|
@ -50,6 +53,6 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-warning" role="alert">There are no active offers with the current filter.</div>
|
||||
<div class="alert alert-warning" role="alert">{% trans 'There are no active offers with the current filter.' %}</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
<h1>Welcome to pflänz.li!</h1>
|
||||
|
||||
<h3>Please confirm your email</h3>
|
||||
|
||||
<h1>{% trans "Welcome to pflänz.li" %}!</h1>
|
||||
<h3>{% trans "Please confirm your email" %}</h3>
|
||||
<p>
|
||||
Please confirm your email address by clicking the following link: <br><br>
|
||||
<a href="{{ signedUrl|raw }}">Confirm my Email</a>.
|
||||
This link will expire in {{ expiresAtMessageKey|trans(expiresAtMessageData, 'VerifyEmailBundle') }}.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Cheers!
|
||||
{% trans "Please confirm your email address by clicking the following link" %}:
|
||||
<br>
|
||||
<br>
|
||||
<a href="{{ signedUrl|raw }}">{% trans "Confirm my email" %}</a>.
|
||||
{% trans "This link will expire in" %} {{ expiresAtMessageKey|trans(expiresAtMessageData, 'VerifyEmailBundle') }}.
|
||||
</p>
|
||||
<p>Cheers!</p>
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% load crispy_forms_tags %}
|
||||
{% block content %}
|
||||
{% if next %}
|
||||
{% if user.is_authenticated %}
|
||||
<p>Your account doesn't have access to this page. To proceed, please login with an account that has access.</p>
|
||||
<div class="alert alert-warning">
|
||||
{% trans "Your account doesn't have access to this page. To proceed, please login with an account that has access." %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p>Please login to see this page.</p>
|
||||
<div class="alert alert-info">{% trans "Please login to see this page." %}</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<h1 class="mb-3">Login</h1>
|
||||
|
@ -16,6 +19,6 @@
|
|||
<input type="hidden" name="next" value="{{ next }}">
|
||||
</form>
|
||||
<p>
|
||||
<a href="{% url 'password_reset' %}">Forgot password?</a>
|
||||
<a href="{% url 'password_reset' %}">{% trans "Forgot password?" %}</a>
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block content %}
|
||||
<h1>Reset password</h1>
|
||||
<p>New password was set successfully. Please login again.</p>
|
||||
<h1>{% trans "Reset password" %}</h1>
|
||||
<p>{% trans "New password was set successfully. Please login again." %}</p>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% load crispy_forms_tags %}
|
||||
{% block content %}
|
||||
<h1>Reset password</h1>
|
||||
<p>Choose a new password.</p>
|
||||
<h1>{% trans "Reset password" %}</h1>
|
||||
<p>{% trans "Choose a new password." %}</p>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
{% block title %}Register{% endblock %}
|
||||
{% load i18n %}
|
||||
{% block title %}
|
||||
{% trans "Register" %}
|
||||
{% endblock %}
|
||||
{% block meta %}<meta name="description" content="Register for pflänz.li" />{% endblock %}
|
||||
{% block javascripts %}{{ encore_entry_script_tags('captcha') }}{% endblock %}
|
||||
{% block content %}
|
||||
|
@ -9,7 +12,7 @@
|
|||
{% for message in app.flashes('error') %}
|
||||
<div class="alert alert-danger" role="alert">{{ message }}</div>
|
||||
{% endfor %}
|
||||
<h1>Register</h1>
|
||||
<h1>{% trans "Register" %}</h1>
|
||||
{{ form_start(registrationForm) }}
|
||||
{{ form_widget(registrationForm) }}
|
||||
<div class="form-group row">
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% load crispy_forms_tags %}
|
||||
{% block content %}
|
||||
<h1>Reset password</h1>
|
||||
<p>Enter the email of your account, you'll then recieve a reset link.</p>
|
||||
<h1>{% trans "Reset password" %}</h1>
|
||||
<p>{% trans "Enter the email of your account, you'll then recieve a reset link." %}</p>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block content %}
|
||||
<h1>Reset password</h1>
|
||||
<h1>{% trans "Reset password" %}</h1>
|
||||
<p>
|
||||
We've emailed you instructions for setting your password, if an account exists with the email you entered. You should receive them shortly.
|
||||
{% trans "We've emailed you instructions for setting your password, if an account exists with the email you entered. You should receive them shortly." %}
|
||||
</p>
|
||||
<p>
|
||||
If you don't receive an email, please make sure you've entered the address you registered with, and check your spam folder.
|
||||
{% trans "If you don't receive an email, please make sure you've entered the address you registered with, and check your spam folder." %}
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}User{% endblock %}
|
||||
{% block content %}
|
||||
<h1 class="mb-4">
|
||||
User details <span class="badge bg-secondary">{{ user.username }}</span>
|
||||
</h1>
|
||||
<div class="alert alert-warning">Some functions do not work yet!</div>
|
||||
<div class="alert alert-warning">{% trans "Some functions do not work yet!" %}</div>
|
||||
<div class="mb-5">
|
||||
<h2>Settings</h2>
|
||||
<a class="btn btn-pfl" href="{% url 'user_edit' %}">Edit Account</a>
|
||||
<h2>{% trans "Settings" %}</h2>
|
||||
<a class="btn btn-pfl" href="{% url 'user_edit' %}">{% trans "Edit Account" %}</a>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<h2>Delete Account</h2>
|
||||
<h2>{% trans "Delete Account" %}</h2>
|
||||
<button class="btn btn-danger">
|
||||
<i class="me-1 fa-solid fa-triangle-exclamation"></i>Delete Account
|
||||
<i class="me-1 fa-solid fa-triangle-exclamation"></i>{% trans "Delete Account" %}
|
||||
</button>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{% block title %}User {{ username }}{% endblock %}
|
||||
{% block content %}
|
||||
<div class="mb-3">
|
||||
<h1>{{ user.username }}'s Profile</h1>
|
||||
<h1>{{ user.username }}'s {% trans "Profile" %}</h1>
|
||||
</div>
|
||||
<h2 class="h3">Wishlist</h2>
|
||||
<div class="mb-4">
|
||||
|
@ -12,7 +12,7 @@
|
|||
{% for wish in wishes %}<li class="list-group-item">{{ wish.title }}</li>{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<div class="alert alert-warning" role="alert">{{ user.username }} has currently no wishes!</div>
|
||||
<div class="alert alert-warning" role="alert">{{ user.username }} {% trans "has currently no wishes" %}!</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
|
@ -46,6 +46,6 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-warning" role="alert">There are currently no active offers.</div>
|
||||
<div class="alert alert-warning" role="alert">{% trans "There are currently no active offers" %}.</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<p>Hello {{ recipient_user.username }}</p>
|
||||
<h1>{{ sender_user.username }} wants to trade '{{ offer.title }}'!</h1>
|
||||
<p>Checkout their offers:</p>
|
||||
<a href="{{ request.scheme }}://{{ request.get_host }}{% url 'user_detail' sender_user.id %}">Link</a>
|
||||
<p>Just reply to get in contact with {{ sender_user.username }}.</p>
|
||||
{% load i18n %}
|
||||
<p>{% trans "Hello" %} {{ recipient_user.username }}</p>
|
||||
<h1>{{ sender_user.username }} {% trans "is interested in" %} '{{ offer.title }}'!</h1>
|
||||
<p>{% trans "Checkout their offers" %}:</p>
|
||||
<a href="{{ request.scheme }}://{{ request.get_host }}{% url 'user_detail' sender_user.id %}">{{ request.user.username }}'s {% trans "offers" %}</a>
|
||||
<p>{% trans "Contact" %} {{ sender_user.username }} {% trans "by replying to this mail" %}.</p>
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% load crispy_forms_tags %}
|
||||
{% block title %}Whishlist{% endblock %}
|
||||
{% block title %}
|
||||
{% trans "Wishlist" %}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="mb-3">
|
||||
<h1>{{ title }} Wishlist</h1>
|
||||
<h1>{{ title }}</h1>
|
||||
</div>
|
||||
<div class="mb-5">
|
||||
{% if wishes %}
|
||||
|
@ -25,19 +28,19 @@
|
|||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<div class="alert alert-warning" role="alert">There are currently no wishes!</div>
|
||||
<div class="alert alert-warning" role="alert">{% trans "There are currently no wishes!" %}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if form %}
|
||||
<hr class="mb-5"/>
|
||||
<div class="mb-3">
|
||||
<h3>
|
||||
<i class="fas fa-star"></i> New wish
|
||||
<i class="fas fa-star"></i> {% trans "New wish" %}
|
||||
</h3>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
<button type="submit" class="btn btn-pfl">Add</button>
|
||||
<button type="submit" class="btn btn-pfl">{% trans "Add" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
|
@ -6,6 +6,8 @@ from django.contrib.auth.decorators import login_required
|
|||
from django.views.decorators.csrf import csrf_protect
|
||||
from django.views.decorators.http import require_POST
|
||||
from django.http import HttpResponseForbidden
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
from .forms import CreateOfferForm, RegistrationForm, FilterForm, WishForm
|
||||
|
||||
|
@ -38,12 +40,12 @@ def create_offer(request):
|
|||
offer.user = request.user
|
||||
offer.title = offer.title.title()
|
||||
offer.save()
|
||||
messages.success(request, "Offer uploaded successfully!")
|
||||
messages.success(request, _("Offer uploaded successfully!"))
|
||||
return redirect("offer_detail", offer.id)
|
||||
else:
|
||||
form = CreateOfferForm()
|
||||
|
||||
return render(request, "basic_form.html", {"form": form, "button_label": "Create", "title": "Create Offer"})
|
||||
return render(request, "basic_form.html", {"form": form, "button_label": _("Create"), "title": _("Create offer")})
|
||||
|
||||
|
||||
def offer_detail(request, offer_id):
|
||||
|
@ -71,7 +73,7 @@ def offer_delete(request, offer_id):
|
|||
return HttpResponseForbidden()
|
||||
|
||||
offer.delete()
|
||||
messages.success(request, "Offer deleted successfully!")
|
||||
messages.success(request, _("Offer deleted successfully!"))
|
||||
return redirect("list_offers")
|
||||
|
||||
|
||||
|
@ -88,12 +90,12 @@ def offer_edit(request, offer_id):
|
|||
offer.image.name = generate_unique_filename(form.cleaned_data['image'].name)
|
||||
offer.user = request.user
|
||||
offer.save()
|
||||
messages.success(request, "Offer updated successfully!")
|
||||
messages.success(request, _("Offer updated successfully!"))
|
||||
return redirect("offer_detail", offer.id)
|
||||
else:
|
||||
form = CreateOfferForm(instance=offer)
|
||||
|
||||
return render(request, "basic_form.html", {"form": form, "button_label": "Update", "title": "Edit Offer"})
|
||||
return render(request, "basic_form.html", {"form": form, "button_label": _("Save"), "title": _("Edit Offer")})
|
||||
|
||||
|
||||
@login_required
|
||||
|
@ -101,19 +103,19 @@ def wishlist(request, user_id):
|
|||
wishes = Wish.objects.filter(user=user_id)
|
||||
|
||||
if user_id == request.user.id:
|
||||
title = "Your"
|
||||
title = _("Your wishlist")
|
||||
if request.method == "POST":
|
||||
form = WishForm(request.POST)
|
||||
if form.is_valid():
|
||||
wish = form.save(commit=False)
|
||||
wish.user = request.user
|
||||
wish.save()
|
||||
messages.success(request, "Wish added successfully!")
|
||||
messages.success(request, _("Wish added successfully!"))
|
||||
form = WishForm()
|
||||
else:
|
||||
form = None
|
||||
user = get_object_or_404(PflaenzliUser, id=user_id)
|
||||
title = f"{user.username}'s"
|
||||
title = f"{user.username}'s {_('wishlist')}"
|
||||
|
||||
return render(request, "user/wish.html", {"title": title, "form": form, "wishes": wishes, "own": user_id == request.user.id})
|
||||
|
||||
|
@ -124,12 +126,12 @@ def user_edit(request):
|
|||
form = RegistrationForm(request.POST, instance=request.user)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
messages.success(request, "Account details updated successfully!")
|
||||
messages.success(request, _("Account details updated successfully!"))
|
||||
return redirect("user_profile")
|
||||
else:
|
||||
form = RegistrationForm(instance=request.user)
|
||||
|
||||
return render(request, "basic_form.html", {"form": form, "button_label": "Save", "title": "Edit Account Details"})
|
||||
return render(request, "basic_form.html", {"form": form, "button_label": _("Save"), "title": _("Edit Account Details")})
|
||||
|
||||
|
||||
@csrf_protect
|
||||
|
@ -155,9 +157,9 @@ def offer_trade(request, offer_id):
|
|||
|
||||
if sender != recipient:
|
||||
send_offer_email(request, offer, sender, recipient)
|
||||
messages.success(request, f"{recipient.username} was successfully notified")
|
||||
messages.success(request, f"{recipient.username} {_('was successfully notified')}!")
|
||||
else:
|
||||
messages.error(request, "You can't trade with yourself!")
|
||||
messages.error(request, _("You can't trade with yourself!"))
|
||||
|
||||
return redirect("offer_detail", offer_id)
|
||||
|
||||
|
@ -180,7 +182,7 @@ def register_user(request):
|
|||
else:
|
||||
form = RegistrationForm()
|
||||
|
||||
return render(request, "basic_form.html", {"form": form, "button_label": "Register", "title": "Registeration"})
|
||||
return render(request, "basic_form.html", {"form": form, "button_label": _("Register"), "title": _("Registeration")})
|
||||
|
||||
|
||||
def filter_offers(offers, form):
|
||||
|
|
|
@ -129,7 +129,11 @@ LOGOUT_REDIRECT_URL = "/"
|
|||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/4.1/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = "en-us"
|
||||
LANGUAGE_CODE = 'de'
|
||||
LANGUAGES = [
|
||||
('de', 'German'),
|
||||
('en', 'English'),
|
||||
]
|
||||
|
||||
TIME_ZONE = "Europe/Zurich"
|
||||
|
||||
|
|
Loading…
Reference in a new issue