@@ -187,17 +187,24 @@ def get(self, problemID):
187
187
188
188
class EntryListAPI (Resource ):
189
189
def __init__ (self ):
190
- self .parser = reqparse .RequestParser ()
191
- self .parser .add_argument ("problemID" , type = str , required = True , location = "json" )
192
- self .parser .add_argument ("userID" , type = str , required = True , location = "json" )
193
- self .parser .add_argument ("file" , type = FileStorage , required = True , location = "files" )
194
190
super (EntryListAPI , self ).__init__ ()
195
191
196
192
def get (self ):
197
- return jsonify ([a for a in db .entry .find ({})])
193
+ parser = reqparse .RequestParser ()
194
+ parser .add_argument ("problemID" , type = str , required = False , location = "args" )
195
+
196
+ args = parser .parse_args ()
197
+ if args ["problemID" ] is not None :
198
+ return jsonify ([a for a in db .entry .find ({"problemID" : args ["problemID" ]})])
199
+ else :
200
+ return jsonify ([a for a in db .entry .find ({})])
198
201
199
202
def post (self ):
200
- entry = self .parser .parse_args ()
203
+ parser = reqparse .RequestParser ()
204
+ parser .add_argument ("problemID" , type = str , required = True , location = "json" )
205
+ parser .add_argument ("userID" , type = str , required = True , location = "json" )
206
+ parser .add_argument ("file" , type = FileStorage , required = True , location = "files" )
207
+ entry = parser .parse_args ()
201
208
202
209
try :
203
210
if db .problem .find_one ({"_id" : ObjectId (entry ['problemID' ])}) == None :
@@ -223,7 +230,6 @@ def post(self):
223
230
status_code = 400
224
231
225
232
return jsonify (structuredGradingOutput , status = status_code )
226
-
227
233
class EntryAPI (Resource ):
228
234
def get (self , entryID ):
229
235
try :
0 commit comments