Tweaked rom model and added form
This commit is contained in:
parent
b5de5de5e8
commit
1aa678778e
|
@ -0,0 +1,9 @@
|
|||
from django.forms import ModelForm
|
||||
|
||||
from roms.models import Rom
|
||||
|
||||
|
||||
class RomUploadForm(ModelForm)
|
||||
class Meta:
|
||||
model = Rom
|
||||
fields = ['name', 'description', 'cover', 'low_binary', 'high_binary', 'tags']
|
|
@ -0,0 +1,40 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.6 on 2017-05-08 21:36
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
import roms.models
|
||||
import stdimage.models
|
||||
import stdimage.validators
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('roms', '0003_auto_20170506_2213'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='rom',
|
||||
name='creation_time',
|
||||
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now, verbose_name='creation time'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='rom',
|
||||
name='edit_time',
|
||||
field=models.DateTimeField(auto_now=True, verbose_name='edit time'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='rom',
|
||||
name='cover',
|
||||
field=stdimage.models.StdImageField(upload_to=roms.models.upload_cover_to, validators=[stdimage.validators.MinSizeValidator(300, 300)], verbose_name='cover image'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='rom',
|
||||
name='name',
|
||||
field=models.CharField(max_length=128, unique=True, verbose_name='name'),
|
||||
),
|
||||
]
|
|
@ -18,17 +18,20 @@ def upload_binary_to(instance, filename):
|
|||
|
||||
|
||||
class Rom(models.Model):
|
||||
name = models.CharField("name", max_length = 128)
|
||||
name = models.CharField("name", max_length = 128, unique=True)
|
||||
description = models.TextField("description")
|
||||
cover = StdImageField("cover image",
|
||||
upload_to = upload_cover_to,
|
||||
validators = [MinSizeValidator(300,300)],
|
||||
variations = {'large': {'width': 600, 'height': 600, 'crop': True},
|
||||
'small': {'width': 300, 'height': 300, 'crop': True}})
|
||||
low_binary = models.FileField("low binary", upload_to=upload_binary_to)
|
||||
high_binary = models.FileField("high binary", upload_to=upload_binary_to)
|
||||
low_binary = models.FileField("low binary", upload_to = upload_binary_to)
|
||||
high_binary = models.FileField("high binary", upload_to = upload_binary_to)
|
||||
approved = models.BooleanField("approved")
|
||||
tags = TaggableManager(blank = True)
|
||||
creation_time = models.DateTimeField("creation time", auto_now_add = True)
|
||||
edit_time = models.DateTimeField("edit time", auto_now = True)
|
||||
|
||||
|
||||
def tag_list(self):
|
||||
return [t.name for t in self.tags.all()]
|
||||
|
|
Loading…
Reference in New Issue