Skip to content
Snippets Groups Projects
Unverified Commit a4c2d173 authored by Máté Bodor's avatar Máté Bodor Committed by GitHub
Browse files

Merge pull request #41 from DevTeamSCH/note

Note
parents 12ff1915 c7037278
No related branches found
No related tags found
No related merge requests found
Pipeline #3164 failed
from django.core.mail import send_mail
import codecs
sender_email = 'noreply@kszkepzes.sch.bme.hu'
link = 'kszkepzes.sch.bme.hu/homework'
sender_email = 'noreply@ujonc.sch.bme.hu'
link = 'https://ujonc.sch.bme.hu/homework'
def read_email(name):
......
Kedves %(name)s!
Szia!
Örömmel vettük jelenkezésedet az idei KSZKépzés programunkba. Azonban ahhoz, hogy ezt el is tudjuk bírálni, még szükségünk van pár dologra tőled:
- ki kell töltened a profilodat,
......
import os
from django.db import models
from django.core import validators
from django.dispatch import receiver
from account.models import Profile
from homework.models import Solution
from common.validators import FileSizeValidator
def document_file_name(instance, filename):
return '/'.join([
'document',
instance.solution.task.title,
instance.uploaded_by.full_name,
filename
])
class Document(models.Model):
uploaded_by = models.ForeignKey(Profile, on_delete=models.DO_NOTHING)
uploaded_at = models.DateTimeField(auto_now_add=True, editable=False)
......@@ -22,9 +33,18 @@ class Document(models.Model):
FileSizeValidator(size_limit=52428800), # 52428800 - 50MiB
],
blank=True,
null=True
null=True,
upload_to=document_file_name
)
solution = models.ForeignKey(Solution, related_name='files', on_delete=models.CASCADE)
def __str__(self):
return self.name
# Deletes file from filesystem when File object is deleted.
@receiver(models.signals.post_delete, sender=Document)
def auto_delete_file_on_delete(sender, instance, **kwargs):
if instance.file:
if os.path.isfile(instance.file.path):
os.remove(instance.file.path)
......@@ -25,9 +25,9 @@ class NoteViewSet(viewsets.ModelViewSet):
profile_id = self.request.query_params.get('profileID', None)
event_id = self.request.query_params.get('eventID', None)
if profile_id is not None and event_id is not None:
return queryset.filter(user=profile_id, event=event_id)
return queryset.filter(profile=profile_id, event=event_id)
if profile_id is not None:
return queryset.filter(user=profile_id)
return queryset.filter(profile=profile_id)
if event_id is not None:
return queryset.filter(event=event_id)
return queryset
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment