Ejemplo n.º 1
0
def package_edit( request, package_name ):
    #assert False, package_name
    from fl.packages.forms import PackageForm
    package = get_object_or_404(Package, name = package_name)
    profile = request.user.get_profile()
    if request.POST:
        pkgform = PackageForm(request.POST, instance=package)
        if pkgform.is_valid():
            pkgform.save()
            m = Meteora(True,"Package %s Saved" % package.name )
            m.notebook_close_page("nbPackage","edit")
            m.notebook_select_page("nbPackage","index")
            return m.json_response()
        else:
            m = Meteora(False,"error")
            m.form_invalid(pkgform)
            return m.json_response()
    else:
        if profile.is_community():
            pkgForm = PackageForm(instance=package)
        else:
            pkgForm = None

        statusForm = None
        return  render_to_response("packages/package_edit.html",
            { "package": package,'statusform': statusForm,'packageform':pkgForm },
             context_instance=RequestContext(request))
Ejemplo n.º 2
0
def login(request, template_name='meteora/login.html', redirect_field_name=REDIRECT_FIELD_NAME):
    "Displays the login form and handles the login action."
    redirect_to = request.REQUEST.get(redirect_field_name, '')
    if request.method == "POST":
        form = MeteoraAuthenticationForm(data=request.POST)
        if form.is_valid():
            # Light security check -- make sure redirect_to isn't garbage.
            if not redirect_to or '//' in redirect_to or '' in redirect_to:
                from django.conf import settings
                redirect_to = settings.LOGIN_REDIRECT_URL
                print "redirect_to: %s" % redirect_to
            from django.contrib.auth import login
            login(request, form.get_user())
            if request.session.test_cookie_worked():
                request.session.delete_test_cookie()
            m = Meteora()
            m.redirectTo(redirect_to)
            return m.json_response()
        else:
            m = Meteora(False, "Invalid Form")
            m.form_invalid("table-login",form)
            return m.json_response()
    else:
        form = MeteoraAuthenticationForm(request)
    request.session.set_test_cookie()
    return render_to_response(template_name, {
        'form': form,
        redirect_field_name: redirect_to
    }, context_instance=RequestContext(request))
Ejemplo n.º 3
0
def datagrid_json(request):
    if not request.POST:
        people = Person.objects.all()
        a = [dict(id="id", name="Name", phone="Phone", birthdate="BirthDate")]
        for p in people:
            d = dict(id=p.id, name=p.name, phone=p.phone, birthdate=str(p.birthdate))
            a.append(d)
        return json(a)
    else:
        list_pk = request.POST.getlist("pk[]")
        list_name = request.POST.getlist("name[]")
        list_phone = request.POST.getlist("phone[]")
        list_birthdate = request.POST.getlist("birthdate[]")

        for index, pk in enumerate(list_pk):
            if not pk:
                break
            p = Person.objects.get(id=pk)
            p.name = list_name[index]
            p.phone = list_phone[index]
            p.birthdate = list_birthdate[index]
            p.save()
        m = Meteora(True, "Update Success")
        m.execute("document.datagridTest.update();")
        return m.json_response()
Ejemplo n.º 4
0
def package_asign(request, package_id):
    package, success = m_get_or_404(Package, id = package_id)
    if not success:
        return package
    profile = request.user.get_profile()
    profile.packages.add(package)
    m = Meteora(True,"Change the %s to user %s" % (package.name, request.user.username))
    m.update_object("package_%s" % package.name,"%s" % request.user.username)
    return m.json_response()
Ejemplo n.º 5
0
def register(request):
    if request.POST:
        form = UserCreationForm(request.POST)
        if form.is_valid():
            user = form.save()
            p = Profile.objects.create(user=user)
            group_community = get_object_or_404(Group, name = "community")
            user.groups.add(group_community)
            m = Meteora(True, "New user: %s register" %user.username)
            m.redirectTo(reverse('fl.auth.views.login'))
            return m.json_response()
        else:
            m = Meteora(False, "Form Invalid")
            m.form_invalid(form)
            return m.json_response()
    else:
        form = UserCreationForm()
        return render_to_response("registration/register.html", {'form':form})
Ejemplo n.º 6
0
def package_change_status(request, package_id ):
    package, success = m_get_or_404(Package, id = package_id)
    if request.method == "POST":
        if not success:
            return package
        if package.status == 1:
            package.status = 2
        elif package.status == 2:
            package.status = 3
            if not request.user.get_profile().is_developer():
               package.status = 1
        elif package.status == 3:
            package.status = 1
        package.save()
        m = Meteora(True, "Status change to: %s" % package.get_status())
        m.update_object("status", package.get_status())
        return m.json_response()
    else:
        from fl.packages.forms import JiraLoginForm
        return  render_to_response("packages/package_status_change.html",
            { 'jiraform':JiraLoginForm(), 'package':package },
             context_instance=RequestContext(request))
Ejemplo n.º 7
0
def form_json(request):
    m = Meteora(True, "Send success")
    return m.json_response()