This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyCustomUser(models.Model): | |
# user fields | |
def save(self, *args, **kwargs): | |
super(MyCustomUser, self).save(*args, **kwargs) | |
profile = MyUserProfile(user=self) | |
profile.save() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.dispatch import receiver | |
from django.db.models.signals import post_save | |
from .models import * | |
@receiver(post_save, sender=MyCustomUser) | |
def build_profile_on_user_creation(sender, instance, created, **kwargs): | |
if created: | |
profile = MyProfile(user=instance) | |
profile.save() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from django.contrib.auth.admin import UserAdmin | |
from django.contrib.auth.forms import UserCreationForm | |
from .models import * | |
class UserAdmin(UserAdmin): | |
add_form = BlogUserCreationForm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from .models import * | |
class AuctionAdmin(admin.ModelAdmin): | |
list_display = ['title', 'current_bid_display', 'bid_count', 'expiry_date', 'active'] | |
def current_bid_display(self, obj): | |
return "£{0}".format(obj.current_bid) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.management.base import BaseCommand, CommandError | |
from crunchy_waffles_app.models import * | |
from django.utils import timezone | |
class Command(BaseCommand): | |
help = 'Closes or opens auctions based their individual DateTime values' | |
def add_arguments(self, parser): | |
parser.add_argument('--id') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EmailAdmin(admin.ModelAdmin): | |
list_display = ['auction', 'email_to', 'created_at'] | |
list_filter = ( | |
('auction',) | |
) | |
def email_to(self, obj): | |
return obj.owner.email |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from crunchy_waffles_app.models import EmailQueue | |
class BiddingActions(): | |
auction = None | |
def __init__(self, instance): | |
self.auction = instance | |
def update_auction(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.management.base import BaseCommand, CommandError | |
from crunchy_waffles_app.models import * | |
class Command(BaseCommand): | |
help = 'Runs through email queue and sends emails' | |
def add_arguments(self, parser): | |
parser.add_argument('--id') | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from .models import * | |
class ManagementAdmin(admin.ModelAdmin): | |
list_display = ['task', 'count', 'started', 'finished', 'state'] | |
admin.site.register(ManagementLog, ManagementAdmin) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from crunchy_waffles_ops.models import * | |
from django.utils import timezone | |
class Management: | |
log = None | |
def __init__(self, title): | |
self.log = ManagementLog(task=title, count=0, started=timezone.now(), state=1) |
OlderNewer