Changeset - 54ae2c7b068c
[Not reviewed]
0 2 1
Ben Sturmfels (bsturmfels) - 1 month ago 2024-07-29 13:44:40
ben@sturm.com.au
usethesource: Add admin interface
3 files changed with 30 insertions and 1 deletions:
0 comments (0 inline, 0 general)
conservancy/usethesource/admin.py
Show inline comments
 
from django.contrib import admin
 

	
 
from .emails import make_candidate_email
 
from .models import Candidate, Comment
 
from .models import Candidate, Comment, SourceOffer
 

	
 

	
 
class CommentInline(admin.TabularInline):
...
 
@@ -36,3 +36,10 @@ class CandidateAdmin(admin.ModelAdmin):
 
            # Announce the new candidate
 
            email = make_candidate_email(obj, request.user)
 
            email.send()
 

	
 

	
 
@admin.register(SourceOffer)
 
class SourceOfferAdmin(admin.ModelAdmin):
 
    list_display = ['time', 'vendor', 'device']
 
    fields = ['time', 'vendor', 'device', 'photo']
 
    readonly_fields = ['time']
conservancy/usethesource/migrations/0010_sourceoffer_time.py
Show inline comments
 
new file 100644
 
# Generated by Django 4.2.11 on 2024-07-29 09:42
 

	
 
from django.db import migrations, models
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    dependencies = [
 
        ('usethesource', '0009_sourceoffer'),
 
    ]
 

	
 
    operations = [
 
        migrations.AddField(
 
            model_name='sourceoffer',
 
            name='time',
 
            field=models.DateTimeField(auto_now_add=True, null=True),
 
        ),
 
    ]
conservancy/usethesource/models.py
Show inline comments
...
 
@@ -70,6 +70,10 @@ class Comment(models.Model):
 

	
 

	
 
class SourceOffer(models.Model):
 
    time = models.DateTimeField(auto_now_add=True, null=True)
 
    vendor = models.CharField('Vendor name', max_length=50)
 
    device = models.CharField('Device name', max_length=50)
 
    photo = models.ImageField(upload_to='usethesource/offers')
 

	
 
    def __str__(self):
 
        return f'{self.vendor} {self.device}'
0 comments (0 inline, 0 general)