def curator_form(request, object_id, slug): user = request.user full_name = ' '.join([user.first_name, user.last_name]).strip() topic = get_object_or_404(models.Topic, pk=object_id) if request.method == 'POST': form = forms.CombinedForms( user_data=None if full_name else forms.CuratorUserForm(request.POST), curator=forms.CuratorForm(request.POST, request.FILES), ) if form.is_valid(): services.create_curator(user, topic, **form.cleaned_data) return redirect(topic) else: form = forms.CombinedForms( user_data=None if full_name else forms.CuratorUserForm(), curator=forms.CuratorForm(), ) return render( request, 'manopozicija/form.html', { 'page_title': str(topic), 'form_name': 'curator-form', 'form_title': ugettext('Tapk temos kuratoriumi'), 'forms': form.forms, })
def create_topic_curator(topic, user, name, title): user_data = {} user_data['first_name'], user_data['last_name'] = name.split() curator = services.create_curator(user, topic, user_data, { 'title': title, 'photo': None, }) post = curator.posts.first() return post
def curator_form(request, object_id, slug): user = request.user full_name = ' '.join([user.first_name, user.last_name]).strip() topic = get_object_or_404(models.Topic, pk=object_id) if request.method == 'POST': form = forms.CombinedForms( user_data=None if full_name else forms.CuratorUserForm(request.POST), curator=forms.CuratorForm(request.POST, request.FILES), ) if form.is_valid(): services.create_curator(user, topic, **form.cleaned_data) return redirect(topic) else: form = forms.CombinedForms( user_data=None if full_name else forms.CuratorUserForm(), curator=forms.CuratorForm(), ) return render(request, 'manopozicija/form.html', { 'page_title': str(topic), 'form_name': 'curator-form', 'form_title': ugettext('Tapk temos kuratoriumi'), 'forms': form.forms, })