Exemplo n.º 1
0
def unpublish(request, wid):
    wall = Wall.objects.get(id=wid)
 
    update_form = UpdateWallForm()
    update_form.initial['name'] = wall.name
    update_form.fields['name'].label = 'Update WikiWall Name'
    update_form.fields['invited'].label = 'Invite new users by email address'
    
    unpub_form = UnpubWallForm(request.POST or None)
   
    if unpub_form.is_valid():
        box_id = request.POST.get('box_id')
        if box_id in wall.published:
           wall.published.remove(box_id)
           wall.save()
           box = Box.objects.get(id=box_id)
           wall_unpub_msg = 'Publishing Updated - ' 
           wall_unpub_msg += 'wall.name: %s unpublished from  ' % wall.name
           wall_unpub_msg += '|  box.name: %s' % box.name
           messages.success(request, wall_unpub_msg)
        
        box = Box.objects.get(id=box_id)
        if box_id in box.walls:
            box.walls.remove(box_id)
            box.save()
            box_unpub_msg = 'Box Updated Successfully - '
            box_unpub_msg += 'wall.name: %s removed ' % wall.name
            box_unpub_msg += 'from box.published for %s' % box.name
            box.success(request, box_unpub_msg)

        return HttpResponseRedirect('/walls/update/%s' % wid)

    pub_form = PubWallForm(initial={'publish': wall.published})

    data = {'title': 'Kolabria - Unshare Wall with user',
            'wid': wid,
            'pub_form': pub_form,
            'update_form': update_form,
            'unpub_form': unpub_form, 
            'wall': wall,
            }
    return render_to_response('walls/update.html', data,
                              context_instance=RequestContext(request))