Пример #1
0
    def save(self, user=None, *args, **kwargs):
        comment = super(FormComment, self).save(commit=False, *args, **kwargs)
        update = False
        if user and not user.is_anonymous():
            comment.author_id = user.id
            update = True
        if self.cleaned_data.get('content_type_id', None):
            comment.content_type_id = self.cleaned_data['content_type_id']
            update = True
        if self.cleaned_data['parent_id']:
            comment.parent = Comment.objects.get(pk=self.cleaned_data['parent_id'])
            update = True
        if update:
            comment.save()

        send_notifications.send(sender=self, instance=comment)
        return comment
Пример #2
0
    def save(self, user=None, *args, **kwargs):
        comment = super(FormComment, self).save(commit=False, *args, **kwargs)
        update = False
        if user and not user.is_anonymous():
            comment.author_id = user.id
            update = True
        if self.cleaned_data.get('content_type_id', None):
            comment.content_type_id = self.cleaned_data['content_type_id']
            update = True
        if self.cleaned_data['parent_id']:
            comment.parent = Comment.objects.get(
                pk=self.cleaned_data['parent_id'])
            update = True
        if update:
            comment.save()

        send_notifications.send(sender=self, instance=comment)
        return comment
Пример #3
0
def edit_inline_branch(request):
    logger.debug('acessing organization > edit_inline_branch: POST={}'.format(
            request.POST))

    if request.POST.get('id', None):
        branch = get_object_or_404(OrganizationBranch,
            pk=request.POST.get('id', ''))
        branch.info = escape(request.POST['info'])
        name = escape(request.POST.get('name', ''))
        if name:
            branch.name = name
        geometry = request.POST.get('geometry', '')
        if geometry:
            branch.geometry = geometry
        info = markdown.markdown(escape(request.POST['info']))

        communities = request.POST.get('branch_community',
            '').rstrip('|').lstrip('|').split('|')
        branch.save()

        if communities:
            branch.community.clear()
            for comm in communities:
                if comm:
                    branch.community.add(comm)
        branch.save()
        communities = render_to_response(
            'organization/branch_communities_list.html', {'branch': branch},
            context_instance=RequestContext(request)).content
        id_ = branch.id

        success = True
        send_notifications.send(sender=OrganizationBranch, instance=branch)
    else:
        success, info, name, id_ = False, '', '', ''
    return dict(success=success, info=info, name=name, communities=communities,
                id=id_)