Esempio n. 1
0
def export(request, username):
    #username is the profile username from who you want to import the tag tree
    tag_frame_name = request.GET.get('tag_frame_name')  
    force = request.GET.get('force') 
    if request.user.username == username:                  
        return HttpResponse(simplejson.dumps({'type':'error','msg':_('You cannot import tag tree into your own notebook!')}), "application/json")
    else:
        TF = getTagFrame(username)
        tf = TF.objects.get(name=tag_frame_name)
        TFU = getTagFrame(request.user.username)
        #Only warn for the top tag in the tree. For the children and grandchildren, if the user want to import, just merge if user already has in his notebook
        if TFU.objects.filter(name=tag_frame_name).exists() and  force not in true_words:
            #TODO: allow changing the name of the tag
            return HttpResponse(simplejson.dumps({'type':'warning','msg':_('You already have a tag tree of this name in your own notebook!')}), "application/json")
        else:
            #TODO:possible conflicts with the users' own tag trees (for example, if the user alreayd have a tag frame with the same name but with different children)
            #prompt to tell the user s/he already has a tag tree with such a name, and does s/he want to rename the new or the old one? Or replace the old one? Or merge with the old one?
            #For now, the implementation of tag frame will merge the two automatically by default.  
            export_tree(tf, request.user.username)
            
                
        if force in true_words:   
            messages.success(request, _("You have successfully imported the tag tree into your own notebook!")) 
            return HttpResponseRedirect(__get_pre_url(request)) 
        return  HttpResponse(simplejson.dumps({'type':'success','msg':_('You have successfully imported the tag tree into your own notebook!')}), "application/json")
Esempio n. 2
0
def add_groups_2_area(request,username, areaname):
    area = Area.objects.using(request.user.username).get(name=areaname)
    area.owner_name = request.user.username
    group_names = request.POST.getlist('item[tags][]')
    groups = Group.objects.filter(name__in=group_names)
    group_ids = [g.id for g in groups]
    area.add_groups(group_ids)
    return HttpResponseRedirect(__get_pre_url(request)) 
Esempio n. 3
0
def push_tag_frame_2_groups(request, username, tagframe_name):
    tf = Tag_Frame.objects.using(username).get(name=tagframe_name)
    group_names = request.POST.getlist('item[tags][]')
    groups = Group.objects.filter(name__in=group_names)
    #group_ids = [g.id for g in groups]
    for group in groups:
        Group_Tag_Frame.objects.get_or_create(group=group, tag_frame_id=tf.id, tag_frame_owner=request.user.member)
    return HttpResponseRedirect(__get_pre_url(request)) 
Esempio n. 4
0
def push_tag_frame_2_groups(request, username, tagframe_name):
    tf = Tag_Frame.objects.using(username).get(name=tagframe_name)
    group_names = request.POST.getlist('item[tags][]')
    groups = Group.objects.filter(name__in=group_names)
    #group_ids = [g.id for g in groups]
    for group in groups:
        Group_Tag_Frame.objects.get_or_create(
            group=group,
            tag_frame_id=tf.id,
            tag_frame_owner=request.user.member)
    return HttpResponseRedirect(__get_pre_url(request))
Esempio n. 5
0
def export(request, username):
    #username is the profile username from who you want to import the tag tree
    tag_frame_name = request.GET.get('tag_frame_name')
    force = request.GET.get('force')
    if request.user.username == username:
        return HttpResponse(
            simplejson.dumps({
                'type':
                'error',
                'msg':
                _('You cannot import tag tree into your own notebook!')
            }), "application/json")
    else:
        TF = getTagFrame(username)
        tf = TF.objects.get(name=tag_frame_name)
        TFU = getTagFrame(request.user.username)
        #Only warn for the top tag in the tree. For the children and grandchildren, if the user want to import, just merge if user already has in his notebook
        if TFU.objects.filter(
                name=tag_frame_name).exists() and force not in true_words:
            #TODO: allow changing the name of the tag
            return HttpResponse(
                simplejson.dumps({
                    'type':
                    'warning',
                    'msg':
                    _('You already have a tag tree of this name in your own notebook!'
                      )
                }), "application/json")
        else:
            #TODO:possible conflicts with the users' own tag trees (for example, if the user alreayd have a tag frame with the same name but with different children)
            #prompt to tell the user s/he already has a tag tree with such a name, and does s/he want to rename the new or the old one? Or replace the old one? Or merge with the old one?
            #For now, the implementation of tag frame will merge the two automatically by default.
            export_tree(tf, request.user.username)

        if force in true_words:
            messages.success(
                request,
                _("You have successfully imported the tag tree into your own notebook!"
                  ))
            return HttpResponseRedirect(__get_pre_url(request))
        return HttpResponse(
            simplejson.dumps({
                'type':
                'success',
                'msg':
                _('You have successfully imported the tag tree into your own notebook!'
                  )
            }), "application/json")