Drop private pastes.

This commit is contained in:
Julien Palard 2023-04-21 09:18:54 +02:00
parent 60df8bf7b0
commit c1826083fb
Signed by: mdk
GPG Key ID: 0EFC1AC1006886F8
10 changed files with 117 additions and 114 deletions

View File

@ -15,12 +15,10 @@ instance is installed by ansible, the role is available here:
- Support any database supported by Django (Sqlite3, MySQL, PostgreSQL, Oracle, ...)
- Available in english, french .. and easily translatable into another languages.
- Syntax highlighting for a bunch of languages using Pygments.
- Public/private pastes (don't appear in the pastes history).
- Time-based or "page loads"-based pastes expiration.
- Password protection.
- Possibility to enable/disable renderers and to choose the default one.
- Limit pastes size.
- Pastes history.
## Running Pasteque

View File

@ -20,7 +20,6 @@ class PasteForm(ModelForm):
"content",
"lifetime",
"lifecount",
"private",
]
def save(self, commit=True):

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-04-04 15:13+0200\n"
"POT-Creation-Date: 2023-04-21 09:18+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -15,172 +15,185 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: models.py:12
#: paste/models.py:12
msgid "Never expire"
msgstr "Jamais"
#: models.py:13
msgid "5 minutes"
msgstr "5 minutes"
#: models.py:14
msgid "30 minutes"
msgstr "30 minutes"
#: models.py:15
#: paste/models.py:13
msgid "1 hour"
msgstr "1 heure"
#: models.py:16
#: paste/models.py:14
msgid "1 day"
msgstr "1 jour"
#: models.py:17
#: paste/models.py:15
msgid "1 week"
msgstr "1 semaine"
#: templates/404.html:3 templates/404.html.py:5 templates/500.html:3
#: paste/models.py:16
msgid "1 month"
msgstr ""
#: paste/models.py:17
msgid "1 year"
msgstr ""
#: paste/templates/404.html:3 paste/templates/404.html:5
#: paste/templates/500.html:3
msgid "Not found"
msgstr "Non trouvé"
#: templates/404.html:7
#: paste/templates/404.html:7
msgid "Sorry but the page you try to access does not exists"
msgstr "Désolé mais la page à laquelle vous tentez d'accéder n'existe pas"
#: templates/500.html:5
#: paste/templates/500.html:5
msgid "Server error"
msgstr "Erreur système"
#: templates/500.html:7
#: paste/templates/500.html:7
msgid "An error occurred"
msgstr "Une erreur est survenue"
#: templates/base.html:27
msgid "powered by"
msgstr "propulsé par"
#: templates/base.html:30 templates/paste/index.html:4
#: paste/templates/base.html:21 paste/templates/paste/index.html:4
msgid "Paste something"
msgstr "Nouveau collage"
#: templates/base.html:31 templates/paste/history.html:3
msgid "Lasts pastes"
msgstr "Derniers collages"
#: paste/templates/base.html:25
msgid "powered by"
msgstr "propulsé par"
#: templates/paste/expired.html:7
#: paste/templates/paste/expired.html:7
msgid "This paste has expired"
msgstr "Ce collage a expiré"
#: templates/paste/expired.html:8
#: paste/templates/paste/expired.html:8
msgid "Sorry but the paste you try to access has expired"
msgstr "Désolé mais ce collage n'est plus accessible car il a expiré"
#: templates/paste/history.html:9 templates/paste/index.html:11
#: paste/templates/paste/history.html:3
msgid "Lasts pastes"
msgstr "Derniers collages"
#: paste/templates/paste/history.html:10 paste/templates/paste/index.html:21
msgid "Title"
msgstr "Titre"
#: templates/paste/history.html:10 templates/paste/index.html:19
#: templates/paste/paste-meta.html:6
#: paste/templates/paste/history.html:12 paste/templates/paste/index.html:28
#: paste/templates/paste/paste-meta.html:7
msgid "Language"
msgstr "Langage"
#: templates/paste/history.html:11 templates/paste/paste-meta.html:7
#: paste/templates/paste/history.html:13
#: paste/templates/paste/paste-meta.html:8
msgid "Size"
msgstr "Taille"
#: templates/paste/history.html:12 templates/paste/paste-meta.html:8
#: paste/templates/paste/history.html:14
#: paste/templates/paste/paste-meta.html:9
msgid "Paste time"
msgstr "Heure collage"
#: templates/paste/history.html:13 templates/paste/paste-meta.html:9
msgid "User IP"
msgstr "IP utilisateur"
#: templates/paste/history.html:14 templates/paste/paste-meta.html:11
#: paste/templates/paste/history.html:15
#: paste/templates/paste/paste-meta.html:11
msgid "Protection"
msgstr "Protection"
#: templates/paste/history.html:15 templates/paste/paste-meta.html:12
#: paste/templates/paste/history.html:16
#: paste/templates/paste/paste-meta.html:12
msgid "Views"
msgstr "Vues"
#: templates/paste/history.html:25 templates/paste/paste-meta.html:22
#: paste/templates/paste/history.html:27
#: paste/templates/paste/paste-meta.html:20
msgid "locked"
msgstr "verrouillé"
#: templates/paste/history.html:25 templates/paste/paste-meta.html:22
#: paste/templates/paste/history.html:27
#: paste/templates/paste/paste-meta.html:20
msgid "open"
msgstr "ouvert"
#: templates/paste/history.html:30
#: paste/templates/paste/history.html:32
msgid "Nothing has been pasted yet"
msgstr "Rien n'a encore été collé"
#: templates/paste/index.html:27
msgid "Private"
msgstr "Privé"
#: templates/paste/index.html:35
msgid "Content"
msgstr "Contenu"
#: templates/paste/index.html:42 templates/paste/paste-meta.html:13
msgid "Expire time"
msgstr "Expiration temporelle"
#: templates/paste/index.html:50
msgid "Expire allowed views"
msgstr "Expiration nombre d'affichages"
#: templates/paste/index.html:58
msgid "Password protected"
msgstr "Protection par mot de passe"
#: templates/paste/index.html:67
msgid "Paste"
msgstr "Coller"
#: templates/paste/index.html:75
#: paste/templates/paste/index.html:11
msgid "characters left"
msgstr "caractères restants"
#: templates/paste/locked.html:7
#: paste/templates/paste/index.html:13
msgid "Content"
msgstr "Contenu"
#: paste/templates/paste/index.html:39 paste/templates/paste/paste-meta.html:13
msgid "Expire time"
msgstr "Expiration temporelle"
#: paste/templates/paste/index.html:51
msgid "Expire allowed views"
msgstr "Expiration nombre d'affichages"
#: paste/templates/paste/index.html:63
msgid "Password protected"
msgstr "Protection par mot de passe"
#: paste/templates/paste/index.html:74
msgid "Paste"
msgstr "Coller"
#: paste/templates/paste/locked.html:7
msgid "This paste is password protected"
msgstr "Protégé par un mot de passe"
#: templates/paste/locked.html:8
msgid "Please enter the password in the field below to unlock the paste and display it"
msgstr "Veuillez entrer le mot de passe dans le champ ci-dessous pour déverrouiller le collage et l'afficher"
#: paste/templates/paste/locked.html:8
msgid ""
"Please enter the password in the field below to unlock the paste and display "
"it"
msgstr ""
"Veuillez entrer le mot de passe dans le champ ci-dessous pour déverrouiller "
"le collage et l'afficher"
#: templates/paste/locked.html:12
#: paste/templates/paste/locked.html:12
msgid "Password"
msgstr "Mot de passe"
#: templates/paste/locked.html:21
#: paste/templates/paste/locked.html:20
msgid "Unlock"
msgstr "Déverrouiller"
#: templates/paste/paste-meta.html:10
#: paste/templates/paste/paste-meta.html:10
msgid "Visibility"
msgstr "Visibilité"
#: templates/paste/paste-meta.html:21
msgid "private"
msgstr "Privé"
#: templates/paste/paste-meta.html:21
msgid "public"
msgstr "publique"
#: templates/paste/paste-meta.html:24
#: paste/templates/paste/paste-meta.html:22
msgid "None"
msgstr "Aucune"
msgid "Paste expired"
msgstr "Heure collage"
#~ msgid "Private"
#~ msgstr "Privé"
msgid "Plain text"
msgstr "Texte simple"
#~ msgid "private"
#~ msgstr "Privé"
msgid "Expiration time"
msgstr "Heure d'expiration"
#~ msgid "public"
#~ msgstr "publique"
#~ msgid "5 minutes"
#~ msgstr "5 minutes"
#~ msgid "30 minutes"
#~ msgstr "30 minutes"
#~ msgid "User IP"
#~ msgstr "IP utilisateur"
#~ msgid "Paste expired"
#~ msgstr "Heure collage"
#~ msgid "Plain text"
#~ msgstr "Texte simple"
#~ msgid "Expiration time"
#~ msgstr "Heure d'expiration"

View File

@ -0,0 +1,16 @@
# Generated by Django 4.2 on 2023-04-21 07:19
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("paste", "0002_auto_20180513_1644"),
]
operations = [
migrations.RemoveField(
model_name="paste",
name="private",
),
]

View File

@ -60,7 +60,6 @@ class Paste(models.Model):
lifecount = models.IntegerField(default=0, blank=True)
viewcount = models.IntegerField(default=0, editable=False)
expired = models.BooleanField(default=False, editable=False)
private = models.BooleanField(default=False)
password = models.CharField(max_length=128, blank=True)
salt = models.CharField(max_length=36, blank=True)

View File

@ -70,12 +70,6 @@
{{ form.password.errors }}
</div>
<div class="form-check">
{{ form.private|add_class:"form-check-input" }}
<label class="form-check-label" for="id_private">{% trans 'Private' %}</label>
{{ form.private.errors }}
</div>
<div class="col-auto">
<button class="btn btn-primary btn-lg" type="submit">{% trans 'Paste' %}</button>
</div>

View File

@ -17,7 +17,6 @@
<td>{% trans paste.language.name %}</td>
<td>{{ paste.size }}</td>
<td>{{ paste.paste_time }}</td>
<td>{% if paste.private %}<i class="icon-eye-close"> {% trans 'private' %}</i>{% else %}<i class="icon-eye-open"> {% trans 'public' %}</i>{% endif %}</td>
<td>{% if paste.password %}<i class="icon-lock"> {% trans 'locked' %}</i>{% else %}<i class="icon-unlock"> {% trans 'open' %}</i>{% endif %}</td>
<td>{{ paste.viewcount }}{% if paste.lifecount > 0 %}/{{ paste.lifecount }}{% endif %}</td>
<td>{% if paste.expiration_time %}{{ paste.expiration_time }}{% else %}{% trans 'None' %}{% endif %}</td>

View File

@ -6,7 +6,6 @@ from webtools import settings
urlpatterns = [
url(r"^$", views.index, name="index"),
url(r"^history$", views.history, name="history"),
url(r"^static/(?P<path>.*)", serve, {"document_root": settings.STATIC_ROOT}),
url(
r"^paste/(?P<slug>[a-zA-Z0-9-]+)/(?P<renderer>[a-z]+)?$",

View File

@ -23,7 +23,6 @@ def index(request):
{
"language": language.id,
"title": any_file.name,
"private": settings.PASTE["private_by_default"],
"lifetime": settings.PASTE["default_lifetime"],
"content": any_file.read().decode(),
},
@ -43,7 +42,6 @@ def index(request):
)
data["form"] = PasteForm(
initial={
"private": settings.PASTE["private_by_default"],
"lifetime": settings.PASTE["default_lifetime"],
"language": Language.by_name(settings.PASTE["default_language"]).id,
}
@ -84,14 +82,3 @@ def show(request, slug, renderer="pygments"):
if "password" in request.POST:
response.set_cookie("password", request.POST["password"])
return response
def history(request):
"""Display last 25 public non-expired pastes."""
pastes = Paste.objects.filter(private=False, expired=False).order_by("-pk")[:25]
data = {
"pastes": pastes,
"menu": "history",
"default_renderer": settings.PASTE["default_renderer"],
}
return render(request, "paste/history.html", data)

View File

@ -97,7 +97,6 @@ PASTE = {
"has_expire_by_views": False,
"has_meta_table": False,
"show_char_left": False,
"private_by_default": True,
"enabled_renderers": ["pygments", "raw"],
"default_renderer": "pygments",
"max_characters": 100000,