Add image uploading feature for organization (#122)
This commit is contained in:
parent
c00db58cb1
commit
9dd779f4fa
14 changed files with 130 additions and 14 deletions
|
@ -48,6 +48,12 @@ def profile_image_path(profile, filename):
|
|||
return os.path.join(settings.DMOJ_PROFILE_IMAGE_ROOT, new_filename)
|
||||
|
||||
|
||||
def organization_image_path(organization, filename):
|
||||
tail = filename.split(".")[-1]
|
||||
new_filename = f"organization_{organization.id}.{tail}"
|
||||
return os.path.join(settings.DMOJ_ORGANIZATION_IMAGE_ROOT, new_filename)
|
||||
|
||||
|
||||
class Organization(models.Model):
|
||||
name = models.CharField(max_length=128, verbose_name=_("organization title"))
|
||||
slug = models.SlugField(
|
||||
|
@ -104,6 +110,7 @@ class Organization(models.Model):
|
|||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
organization_image = models.ImageField(upload_to=organization_image_path, null=True)
|
||||
logo_override_image = models.CharField(
|
||||
verbose_name=_("Logo override image"),
|
||||
default="",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue