views:

53

answers:

0

I am overriding the admin index.html template by adding at the end:

<h1>Exporting and Validating Users</h1>
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
{% if export_message %}

                <p><strong>{{export_message}}</strong></p>

{% endif %}

<table>
    <tr>
        <td>
            <form action="admin/exportvalidateusers/" method="POST">
                <input type="hidden" name="exportvalidate" value="export"/>
                <h3>Export and Validate Users</h3><input type="submit" value="Export and Validate Users" /> 
            </form>
        </td>
    </tr>
</table>

My view is in the admin_views.py

def exportValidateUsers(request):

    if request.method == 'POST':

        import os

        import subprocess

        test = 1

        task = request.POST['exportvalidate']

        if task == 'export':

            test = os.system("java com.ntkn.usermanagement.ExportUsersDomain /etc/ntkn-lb-user-mgmt/exportusers.properties >& /tmp/javaoutput3")


            if test == 0:

                exp_message = "Export successfully completed"

            else:

                exp_message = "Export not completed"    

        else:
            exp_message = "Task not defined"    

        return render_to_response("admin/index.html", {'export_message': exp_message,},RequestContext(request,{}),)     

    else:

        return render_to_response("admin/UserDataValidation.html",{},RequestContext(request,{}),)

How do I get over this. Thanks.