Subversion Repositories SmartDukaan

Rev

Rev 16801 | Rev 16803 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16801 Rev 16802
Line 163... Line 163...
163
                'JSON was incorrect.')
163
                'JSON was incorrect.')
164
            
164
            
165
            
165
            
166
    def on_post(self, request, resp):
166
    def on_post(self, request, resp):
167
        try:
167
        try:
-
 
168
            filepath = "/tmp/rejectfile"
168
            print request.stream.read()
169
            with open(filepath,'w') as f:
169
            uploadfile = request.files.get('rejects')
170
                f.write(request.stream.read())
170
            ext = uploadfile.filename.split(".")[1]
171
            ext = request.get_param("rejects")
171
            if ext not in ['.xls','.xlsx']:
172
            if ext not in ['.xls','.xlsx']:
172
                raise falcon.HTTPError(falcon.HTTP_400, 'Invalid Extension use xls/xlsx', 'Invalid Extension use xls/xlsx')
173
                raise falcon.HTTPError(falcon.HTTP_400, 'Invalid Extension use xls/xlsx', 'Invalid Extension use xls/xlsx')
173
            
-
 
174
            filepath = '/tmp/'+uploadfile.filename
-
 
175
            uploadfile.save(filepath)
-
 
176
            rejectCount = process_rejects(filepath) #this function is not yet implemented
174
            rejectCount = process_rejects(filepath) #this function is not yet implemented
177
            
175
            
178
            resp = """
176
            resp.body = """
179
                <html><head><title>Upload Rejects</title></head><body>
177
                <html><head><title>Upload Rejects</title></head><body>
180
            <h1>Reject Successful</h1>
178
            <h1>Reject Successful</h1>
181
            <h2> %d orders rejected</h2>
179
            <h2> %d orders rejected</h2>
182
   
180
   
183
            </body></html>
181
            </body></html>