from django.db import models
from django.contrib.auth.models import User
import micawber
import cloudinary
import cloudinary.uploader
import cloudinary.api
from cloudinary.models import CloudinaryField

class Submission(models.Model):
    date = models.DateTimeField(auto_now_add=True)
    submitted_at = models.DateTimeField(null=True, blank=True)
    accepted_at = models.DateTimeField(null=True, blank=True)
    accepted_by = models.ForeignKey(User, null=True, blank=True, related_name='accepted_submissions')
    message = models.TextField(blank=True, null=True, help_text='If you\'d like, leave a private message to Denny, Josh, and Jake (not public)')
    name = models.CharField(max_length=200,blank=True, null=True,
            help_text="<b>Your Name, Location</b> would be ideal")
    email = models.CharField(max_length=200,blank=True, null=True, help_text="Give us a way to contact you (not public)")

    text = models.TextField(blank=True, help_text='A story about how Barbara touched your life, or anything else you want to share. <small>(markdown formatting available)</small>')

    @models.permalink
    def get_absolute_url(self):
        return ('submission-edit', tuple(), {'pk': self.id,},)

    @property
    def current_files(self):
        return [x for x in self.image_set.all() if x.file]

    def __unicode__(self):
        return u'Submission by %s (%s)' % (self.name, (self.text or
            '')[:20],)

class Image(models.Model):
    submission = models.ForeignKey(Submission)
    file = models.ImageField()

class Link(models.Model):
    submission = models.ForeignKey(Submission)
    link = models.CharField(max_length=255)
    description = models.CharField(max_length=255, null=True)

    embed = models.TextField(null=True,blank=True)

    def save(self, *args, **kwargs):
        providers = micawber.bootstrap_basic()
        try:
            self.embed = providers.request(self.link)['html']
        except micawber.ProviderException as e:
            self.embed = None
        super(Link,self).save(*args, **kwargs)


4ad0ff1ae72c64fab8fd43fa2dde63aed5a49a02
<mask token>


class Submission(models.Model):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    @models.permalink
    def get_absolute_url(self):
        return 'submission-edit', tuple(), {'pk': self.id}

    @property
    def current_files(self):
        return [x for x in self.image_set.all() if x.file]
    <mask token>


class Image(models.Model):
    submission = models.ForeignKey(Submission)
    file = models.ImageField()


class Link(models.Model):
    submission = models.ForeignKey(Submission)
    link = models.CharField(max_length=255)
    description = models.CharField(max_length=255, null=True)
    embed = models.TextField(null=True, blank=True)

    def save(self, *args, **kwargs):
        providers = micawber.bootstrap_basic()
        try:
            self.embed = providers.request(self.link)['html']
        except micawber.ProviderException as e:
            self.embed = None
        super(Link, self).save(*args, **kwargs)

<mask token>


class Submission(models.Model):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    @models.permalink
    def get_absolute_url(self):
        return 'submission-edit', tuple(), {'pk': self.id}

    @property
    def current_files(self):
        return [x for x in self.image_set.all() if x.file]

    def __unicode__(self):
        return u'Submission by %s (%s)' % (self.name, (self.text or '')[:20])


class Image(models.Model):
    submission = models.ForeignKey(Submission)
    file = models.ImageField()


class Link(models.Model):
    submission = models.ForeignKey(Submission)
    link = models.CharField(max_length=255)
    description = models.CharField(max_length=255, null=True)
    embed = models.TextField(null=True, blank=True)

    def save(self, *args, **kwargs):
        providers = micawber.bootstrap_basic()
        try:
            self.embed = providers.request(self.link)['html']
        except micawber.ProviderException as e:
            self.embed = None
        super(Link, self).save(*args, **kwargs)

<mask token>


class Submission(models.Model):
    date = models.DateTimeField(auto_now_add=True)
    submitted_at = models.DateTimeField(null=True, blank=True)
    accepted_at = models.DateTimeField(null=True, blank=True)
    accepted_by = models.ForeignKey(User, null=True, blank=True,
        related_name='accepted_submissions')
    message = models.TextField(blank=True, null=True, help_text=
        "If you'd like, leave a private message to Denny, Josh, and Jake (not public)"
        )
    name = models.CharField(max_length=200, blank=True, null=True,
        help_text='<b>Your Name, Location</b> would be ideal')
    email = models.CharField(max_length=200, blank=True, null=True,
        help_text='Give us a way to contact you (not public)')
    text = models.TextField(blank=True, help_text=
        'A story about how Barbara touched your life, or anything else you want to share. <small>(markdown formatting available)</small>'
        )

    @models.permalink
    def get_absolute_url(self):
        return 'submission-edit', tuple(), {'pk': self.id}

    @property
    def current_files(self):
        return [x for x in self.image_set.all() if x.file]

    def __unicode__(self):
        return u'Submission by %s (%s)' % (self.name, (self.text or '')[:20])


class Image(models.Model):
    submission = models.ForeignKey(Submission)
    file = models.ImageField()


class Link(models.Model):
    submission = models.ForeignKey(Submission)
    link = models.CharField(max_length=255)
    description = models.CharField(max_length=255, null=True)
    embed = models.TextField(null=True, blank=True)

    def save(self, *args, **kwargs):
        providers = micawber.bootstrap_basic()
        try:
            self.embed = providers.request(self.link)['html']
        except micawber.ProviderException as e:
            self.embed = None
        super(Link, self).save(*args, **kwargs)

from django.db import models
from django.contrib.auth.models import User
import micawber
import cloudinary
import cloudinary.uploader
import cloudinary.api
from cloudinary.models import CloudinaryField


class Submission(models.Model):
    date = models.DateTimeField(auto_now_add=True)
    submitted_at = models.DateTimeField(null=True, blank=True)
    accepted_at = models.DateTimeField(null=True, blank=True)
    accepted_by = models.ForeignKey(User, null=True, blank=True,
        related_name='accepted_submissions')
    message = models.TextField(blank=True, null=True, help_text=
        "If you'd like, leave a private message to Denny, Josh, and Jake (not public)"
        )
    name = models.CharField(max_length=200, blank=True, null=True,
        help_text='<b>Your Name, Location</b> would be ideal')
    email = models.CharField(max_length=200, blank=True, null=True,
        help_text='Give us a way to contact you (not public)')
    text = models.TextField(blank=True, help_text=
        'A story about how Barbara touched your life, or anything else you want to share. <small>(markdown formatting available)</small>'
        )

    @models.permalink
    def get_absolute_url(self):
        return 'submission-edit', tuple(), {'pk': self.id}

    @property
    def current_files(self):
        return [x for x in self.image_set.all() if x.file]

    def __unicode__(self):
        return u'Submission by %s (%s)' % (self.name, (self.text or '')[:20])


class Image(models.Model):
    submission = models.ForeignKey(Submission)
    file = models.ImageField()


class Link(models.Model):
    submission = models.ForeignKey(Submission)
    link = models.CharField(max_length=255)
    description = models.CharField(max_length=255, null=True)
    embed = models.TextField(null=True, blank=True)

    def save(self, *args, **kwargs):
        providers = micawber.bootstrap_basic()
        try:
            self.embed = providers.request(self.link)['html']
        except micawber.ProviderException as e:
            self.embed = None
        super(Link, self).save(*args, **kwargs)

from django.db import models
from django.contrib.auth.models import User
import micawber
import cloudinary
import cloudinary.uploader
import cloudinary.api
from cloudinary.models import CloudinaryField

class Submission(models.Model):
    date = models.DateTimeField(auto_now_add=True)
    submitted_at = models.DateTimeField(null=True, blank=True)
    accepted_at = models.DateTimeField(null=True, blank=True)
    accepted_by = models.ForeignKey(User, null=True, blank=True, related_name='accepted_submissions')
    message = models.TextField(blank=True, null=True, help_text='If you\'d like, leave a private message to Denny, Josh, and Jake (not public)')
    name = models.CharField(max_length=200,blank=True, null=True,
            help_text="<b>Your Name, Location</b> would be ideal")
    email = models.CharField(max_length=200,blank=True, null=True, help_text="Give us a way to contact you (not public)")

    text = models.TextField(blank=True, help_text='A story about how Barbara touched your life, or anything else you want to share. <small>(markdown formatting available)</small>')

    @models.permalink
    def get_absolute_url(self):
        return ('submission-edit', tuple(), {'pk': self.id,},)

    @property
    def current_files(self):
        return [x for x in self.image_set.all() if x.file]

    def __unicode__(self):
        return u'Submission by %s (%s)' % (self.name, (self.text or
            '')[:20],)

class Image(models.Model):
    submission = models.ForeignKey(Submission)
    file = models.ImageField()

class Link(models.Model):
    submission = models.ForeignKey(Submission)
    link = models.CharField(max_length=255)
    description = models.CharField(max_length=255, null=True)

    embed = models.TextField(null=True,blank=True)

    def save(self, *args, **kwargs):
        providers = micawber.bootstrap_basic()
        try:
            self.embed = providers.request(self.link)['html']
        except micawber.ProviderException as e:
            self.embed = None
        super(Link,self).save(*args, **kwargs)

