remove thumb generator
This commit is contained in:
@@ -16,5 +16,24 @@ class JobPostingAdmin(admin.ModelAdmin):
|
|||||||
"publish_date",
|
"publish_date",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def add_view(self, request, form_url="", extra_context=None):
|
||||||
|
extra_context = extra_context or {}
|
||||||
|
extra_context["help_text"] = "Fette Schriften sind Pflichtfelder."
|
||||||
|
return super().add_view(
|
||||||
|
request,
|
||||||
|
form_url,
|
||||||
|
extra_context=extra_context,
|
||||||
|
)
|
||||||
|
|
||||||
|
def change_view(self, request, object_id, form_url="", extra_context=None):
|
||||||
|
extra_context = extra_context or {}
|
||||||
|
extra_context["help_text"] = "Fette Schriften sind Pflichtfelder."
|
||||||
|
return super().change_view(
|
||||||
|
request,
|
||||||
|
object_id,
|
||||||
|
form_url,
|
||||||
|
extra_context=extra_context,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(JobPosting, JobPostingAdmin)
|
admin.site.register(JobPosting, JobPostingAdmin)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class JobPostingForm(forms.ModelForm):
|
|||||||
}
|
}
|
||||||
|
|
||||||
help_texts = {
|
help_texts = {
|
||||||
"pdf_location": _("Verwendbare Formate: PDF"),
|
"pdf_location": _("Verwendbares Format: PDF."),
|
||||||
"salary": _(
|
"salary": _(
|
||||||
"in Euro angeben; monatliches Gehalt bei >1h, sonst Stundenlohn."
|
"in Euro angeben; monatliches Gehalt bei >1h, sonst Stundenlohn."
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 4.0.3 on 2022-04-09 08:02
|
||||||
|
|
||||||
|
import django.core.validators
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('blackboard', '0003_auto_20210624_1503'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='jobposting',
|
||||||
|
name='pdf_thumb_location',
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='jobposting',
|
||||||
|
name='pdf_location',
|
||||||
|
field=models.FileField(upload_to='uploads/blackboard/pdf/', validators=[django.core.validators.FileExtensionValidator(['pdf'])], verbose_name='Stellenausschreibung'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -3,10 +3,8 @@ import logging
|
|||||||
import os
|
import os
|
||||||
from os.path import splitext, basename
|
from os.path import splitext, basename
|
||||||
|
|
||||||
import ghostscript
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.validators import ValidationError
|
from django.core.validators import ValidationError, FileExtensionValidator
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@@ -33,9 +31,10 @@ class JobPosting(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
pdf_location = models.FileField(
|
pdf_location = models.FileField(
|
||||||
verbose_name="Stellenausschreibung", upload_to="uploads/blackboard/pdf/"
|
verbose_name="Stellenausschreibung",
|
||||||
|
upload_to="uploads/blackboard/pdf/",
|
||||||
|
validators=[FileExtensionValidator(["pdf"])],
|
||||||
)
|
)
|
||||||
pdf_thumb_location = models.CharField(max_length=128)
|
|
||||||
|
|
||||||
publish_date = models.DateField(
|
publish_date = models.DateField(
|
||||||
verbose_name="Veröffentlichung", default=timezone.now
|
verbose_name="Veröffentlichung", default=timezone.now
|
||||||
@@ -52,52 +51,3 @@ class JobPosting(models.Model):
|
|||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse("blackboard")
|
return reverse("blackboard")
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
|
||||||
super().save(*args, **kwargs)
|
|
||||||
|
|
||||||
if not os.path.exists(settings.MEDIA_ROOT + "uploads/blackboard/thumb/"):
|
|
||||||
os.makedirs(settings.MEDIA_ROOT + "uploads/blackboard/thumb/")
|
|
||||||
|
|
||||||
pdf_thumb_location_full = (
|
|
||||||
settings.MEDIA_ROOT
|
|
||||||
+ "uploads/blackboard/thumb/"
|
|
||||||
+ splitext(basename(self.pdf_location.name))[0]
|
|
||||||
+ ".jpg"
|
|
||||||
)
|
|
||||||
|
|
||||||
self.pdf_thumb_location = (
|
|
||||||
"/files/uploads/blackboard/thumb/"
|
|
||||||
+ splitext(basename(self.pdf_location.name))[0]
|
|
||||||
+ ".jpg"
|
|
||||||
)
|
|
||||||
|
|
||||||
self.pdf2jpeg(self.pdf_location.path, pdf_thumb_location_full)
|
|
||||||
logger.info("SavenThumbAs: " + self.pdf_thumb_location)
|
|
||||||
super().save(*args, **kwargs)
|
|
||||||
|
|
||||||
def clean(self):
|
|
||||||
count = 0
|
|
||||||
for i in self.pdf_location.name:
|
|
||||||
if i == ".":
|
|
||||||
count = count + 1
|
|
||||||
if count > 1: # if more than one dot in filename
|
|
||||||
raise ValidationError(_("Keine Dateien mit >1 Punkten im Namen erlaubt."))
|
|
||||||
|
|
||||||
def pdf2jpeg(self, pdf_input_path, jpeg_output_path):
|
|
||||||
args = [
|
|
||||||
"pef2jpeg", # actual value doesn't matter
|
|
||||||
"-dNOPAUSE",
|
|
||||||
"-sDEVICE=jpeg",
|
|
||||||
"-dDEVICEWIDTHPOINTS=600",
|
|
||||||
"-dDEVICEHEIGHTPOINTS=800",
|
|
||||||
"-sOutputFile=" + jpeg_output_path,
|
|
||||||
pdf_input_path,
|
|
||||||
]
|
|
||||||
|
|
||||||
encoding = locale.getpreferredencoding()
|
|
||||||
args = [a.encode(encoding) for a in args]
|
|
||||||
|
|
||||||
# ghostscript.Ghostscript(*args)
|
|
||||||
with ghostscript.Ghostscript(*args) as g:
|
|
||||||
ghostscript.cleanup()
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ def index(request):
|
|||||||
bb_empty = CustomFlatPage.objects.filter(title__iexact="blackboard empty").first()
|
bb_empty = CustomFlatPage.objects.filter(title__iexact="blackboard empty").first()
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"job_postings": job_postings,
|
"job_postings": job_postings.order_by("-publish_date"),
|
||||||
"bb_info": bb_info,
|
"bb_info": bb_info,
|
||||||
"bb_empty": bb_empty,
|
"bb_empty": bb_empty,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ djangorestframework==3.13.1
|
|||||||
easy-thumbnails==2.8.1
|
easy-thumbnails==2.8.1
|
||||||
etherpad-lite==0.5
|
etherpad-lite==0.5
|
||||||
fontawesomefree==6.1.1
|
fontawesomefree==6.1.1
|
||||||
ghostscript==0.7
|
|
||||||
html2text==2020.1.16
|
html2text==2020.1.16
|
||||||
ldap3==2.9.1
|
ldap3==2.9.1
|
||||||
mysqlclient==2.1.0
|
mysqlclient==2.1.0
|
||||||
|
|||||||
Reference in New Issue
Block a user