Skip to content

Instantly share code, notes, and snippets.

@nephthys
Created September 3, 2012 14:45
Show Gist options
  • Save nephthys/3609819 to your computer and use it in GitHub Desktop.
Save nephthys/3609819 to your computer and use it in GitHub Desktop.
obj = News(is_short=form.cleaned_data['is_short'])
obj.save()
post_type = form.save(commit=False)
post_type.content_object = obj
post_type.ip = request.META['REMOTE_ADDR']
post_type.save()
version = Version(news=obj, author=request.user, ip=request.META['REMOTE_ADDR'], \
content=form.cleaned_data['content_news'], is_minor=form.cleaned_data['is_minor'], \
nb_chars=len(form.cleaned_data['content_news']))
version.save()
obj.last_version = version
obj.save()
class NewsForm(ModelForm):
CHOICE_TYPE = (
(0, _('news')),
(1, _('brief'))
)
is_short = forms.BooleanField(label=_('Type'), required=False, widget=forms.RadioSelect(choices=CHOICE_TYPE))
content_news = forms.CharField(label=_('Content'), help_text=_('Write with markdown'), \
widget=forms.Textarea(attrs={'class':'content_area'}))
reason = forms.CharField(label=_('Reason'))
is_minor = forms.BooleanField(label=_('Small contribution'), required=False)
class Meta:
model = PostType
fields = ['is_short', 'title', 'content_news', 'reason', 'category', 'is_minor', 'status', 'is_closed_com']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment