Beispiel #1
0
	def save(self):
		if not self.pk:
			self.pub_date = datetime.datetime.now()
		md = Markdown(safe_mode = True)
		self.description_html = md.convert(self.description_markdown)
		self.showcase_html = md.convert(self.showcase_markdown)
		super(Project, self).save()
Beispiel #2
0
    def save(self):
        """Auto-populate an empty slug field from the Category name and
        if it conflicts with an existing slug then append a number and try
        saving again.
        """
        import re
        from django.template.defaultfilters import slugify
        
        if not self.slug:
            self.slug = slugify(self.name)  # Where self.name is the field used for 'pre-populate from'

        md = Markdown(safe_mode = True)
        self.description_html = md.convert(self.description_markdown)

        while True:
            try:
                super(Event, self).save()
            # Assuming the IntegrityError is due to a slug fight
            except IntegrityError:
                match_obj = re.match(r'^(.*)-(\d+)$', self.slug)
                if match_obj:
                    next_int = int(match_obj.group(2)) + 1
                    self.slug = match_obj.group(1) + '-' + str(next_int)
                else:
                    self.slug += '-2'
            else:
                break
Beispiel #3
0
	def save(self):
		md = Markdown(safe_mode = True)
		self.text_html = md.convert(self.text)
		super(Comment, self).save()
Beispiel #4
0
	def save(self, *args, **kwargs):
		md = Markdown(safe_mode = True)
		self.description_html = md.convert(self.description_markdown)
		super(Profile, self).save()