Exemple #1
0
def new_network(req):
    uset = UserSettings.get_from_user(req.user)
    if not plans.minimum(uset.plan, plans.FEATURE_MIN_NETWORK):
        return _pmrender(req, 'dashboard/network/page_new_upgrade.html')

    if not req.POST:
        return _pmrender(req, 'dashboard/network/page_new.html')

    try:
        net = Network(
            name=req.POST.get('name'),
            owner=req.user,
            image_url=signer.unsign(req.POST.get('image-url')) if req.POST.get('image-url') else None
        )
        net.save()
        net.members.add(req.user)
        net.save()
    except Exception as e:
        print e
        return _pmrender(req,
                         'dashboard/network/page_new.html',
                         {'error': ugettext('Error while saving network details'),
                          'default': req.POST})

    return redirect('network_dashboard', network_id=net.id)
Exemple #2
0
def new_network(req):
    uset = UserSettings.get_from_user(req.user)

    if not req.POST:
        return _pmrender(req, 'dashboard/network/page_new.html')

    try:
        img_url = req.POST.get('image-url')
        net = Network(
            name=req.POST.get('name'),
            owner=req.user,
            image_url=signer.unsign(img_url) if img_url else None
        )
        net.save()
        net.members.add(req.user)
        net.save()
    except Exception as e:
        return _pmrender(req,
                         'dashboard/network/page_new.html',
                         {'error': ugettext('Error while saving network details'),
                          'default': req.POST})

    return redirect('network_dashboard', network_id=net.id)
Exemple #3
0
def new_network(req):
    uset = UserSettings.get_from_user(req.user)

    if not req.POST:
        return _pmrender(req, 'dashboard/network/page_new.html')

    try:
        img_url = req.POST.get('image-url')
        net = Network(name=req.POST.get('name'),
                      owner=req.user,
                      image_url=signer.unsign(img_url) if img_url else None)
        net.save()
        net.members.add(req.user)
        net.save()
    except Exception as e:
        return _pmrender(
            req, 'dashboard/network/page_new.html', {
                'error': ugettext('Error while saving network details'),
                'default': req.POST
            })

    return redirect('network_dashboard', network_id=net.id)