Commit f0a60e1d authored by opelhoward's avatar opelhoward
Browse files

fix accept

parent f0a3d15c
......@@ -24,11 +24,11 @@
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="sconnectionhandler.py" pinned="false" current-in-tab="false">
<file leaf-file-name="sconnectionhandler.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/sconnectionhandler.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="161" max-vertical-offset="8772">
<caret line="21" column="49" selection-start-line="21" selection-start-column="49" selection-end-line="21" selection-end-column="49" />
<state vertical-scroll-proportion="0.51428574" vertical-offset="1349" max-vertical-offset="8806">
<caret line="91" column="40" selection-start-line="91" selection-start-column="40" selection-end-line="91" selection-end-column="40" />
<folding>
<element signature="e#21#32#0" expanded="true" />
</folding>
......@@ -36,10 +36,20 @@
</provider>
</entry>
</file>
<file leaf-file-name="inventory.py" pinned="false" current-in-tab="true">
<file leaf-file-name="sserver.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/sserver.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="157" max-vertical-offset="1921">
<caret line="21" column="0" selection-start-line="21" selection-start-column="0" selection-end-line="21" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="inventory.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/inventory.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.72613066" vertical-offset="0" max-vertical-offset="408">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="408">
<caret line="17" column="58" selection-start-line="17" selection-start-column="58" selection-end-line="17" selection-end-column="58" />
<folding />
</state>
......@@ -61,8 +71,8 @@
<file leaf-file-name="tradebox.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tradebox.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="877" max-vertical-offset="1275">
<caret line="48" column="22" selection-start-line="48" selection-start-column="22" selection-end-line="48" selection-end-column="22" />
<state vertical-scroll-proportion="0.0" vertical-offset="871" max-vertical-offset="1275">
<caret line="59" column="0" selection-start-line="59" selection-start-column="0" selection-end-line="59" selection-end-column="0" />
<folding>
<element signature="e#22#53#0" expanded="true" />
</folding>
......@@ -70,11 +80,21 @@
</provider>
</entry>
</file>
<file leaf-file-name="objectid.py" pinned="false" current-in-tab="false">
<entry file="file://C:/Python34/Lib/site-packages/bson/objectid.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="3132" max-vertical-offset="4845">
<caret line="205" column="0" selection-start-line="205" selection-start-column="0" selection-end-line="205" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="market.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/market.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="452" max-vertical-offset="1122">
<caret line="46" column="20" selection-start-line="46" selection-start-column="20" selection-end-line="46" selection-end-column="20" />
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="1122">
<caret line="8" column="23" selection-start-line="8" selection-start-column="23" selection-end-line="8" selection-end-column="23" />
<folding>
<element signature="e#22#53#0" expanded="true" />
</folding>
......@@ -82,6 +102,16 @@
</provider>
</entry>
</file>
<file leaf-file-name="ssocketio.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/ssocketio.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="656" max-vertical-offset="1054">
<caret line="41" column="38" selection-start-line="41" selection-start-column="33" selection-end-line="41" selection-end-column="38" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="user.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/user.py">
<provider selected="true" editor-type-id="text-editor">
......@@ -99,11 +129,11 @@
<list>
<option value="$PROJECT_DIR$/map.py" />
<option value="$PROJECT_DIR$/sclient.py" />
<option value="$PROJECT_DIR$/tradebox.py" />
<option value="$PROJECT_DIR$/user.py" />
<option value="$PROJECT_DIR$/inventory.py" />
<option value="$PROJECT_DIR$/market.py" />
<option value="$PROJECT_DIR$/tradebox.py" />
<option value="$PROJECT_DIR$/sconnectionhandler.py" />
<option value="$PROJECT_DIR$/inventory.py" />
</list>
</option>
</component>
......@@ -396,6 +426,62 @@
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/sconnectionhandler.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="161" max-vertical-offset="8772">
<caret line="21" column="49" selection-start-line="21" selection-start-column="49" selection-end-line="21" selection-end-column="49" />
<folding>
<element signature="e#21#32#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/inventory.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="408">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/sclient.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="120" max-vertical-offset="2125">
<caret line="20" column="0" selection-start-line="20" selection-start-column="0" selection-end-line="20" selection-end-column="0" />
<folding>
<element signature="e#0#23#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tradebox.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="877" max-vertical-offset="1275">
<caret line="48" column="22" selection-start-line="48" selection-start-column="22" selection-end-line="48" selection-end-column="22" />
<folding>
<element signature="e#22#53#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/market.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="452" max-vertical-offset="1122">
<caret line="46" column="20" selection-start-line="46" selection-start-column="20" selection-end-line="46" selection-end-column="20" />
<folding>
<element signature="e#22#53#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/user.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="554" max-vertical-offset="1207">
<caret line="63" column="32" selection-start-line="63" selection-start-column="32" selection-end-line="63" selection-end-column="32" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/sconnectionhandler.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="8245">
......@@ -647,13 +733,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/sserver.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="1.022613" vertical-offset="409" max-vertical-offset="1921">
<caret line="52" column="42" selection-start-line="52" selection-start-column="35" selection-end-line="52" selection-end-column="42" />
</state>
</provider>
</entry>
<entry file="file://C:/Python34/Lib/json/decoder.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.24623115" vertical-offset="5648" max-vertical-offset="6222">
......@@ -661,20 +740,18 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tradebox.py">
<entry file="file://$PROJECT_DIR$/user.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="872" max-vertical-offset="1275">
<caret line="48" column="22" selection-start-line="48" selection-start-column="22" selection-end-line="48" selection-end-column="22" />
<folding>
<element signature="e#22#53#0" expanded="true" />
</folding>
<state vertical-scroll-proportion="0.0" vertical-offset="605" max-vertical-offset="1207">
<caret line="63" column="32" selection-start-line="63" selection-start-column="32" selection-end-line="63" selection-end-column="32" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/user.py">
<entry file="file://$PROJECT_DIR$/inventory.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="605" max-vertical-offset="1207">
<caret line="63" column="32" selection-start-line="63" selection-start-column="32" selection-end-line="63" selection-end-column="32" />
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="408">
<caret line="17" column="58" selection-start-line="17" selection-start-column="58" selection-end-line="17" selection-end-column="58" />
<folding />
</state>
</provider>
......@@ -689,33 +766,59 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ssocketio.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="656" max-vertical-offset="1054">
<caret line="41" column="38" selection-start-line="41" selection-start-column="33" selection-end-line="41" selection-end-column="38" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/market.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="452" max-vertical-offset="1122">
<caret line="46" column="20" selection-start-line="46" selection-start-column="20" selection-end-line="46" selection-end-column="20" />
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="1122">
<caret line="8" column="23" selection-start-line="8" selection-start-column="23" selection-end-line="8" selection-end-column="23" />
<folding>
<element signature="e#22#53#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/sconnectionhandler.py">
<entry file="file://C:/Python34/Lib/site-packages/bson/objectid.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="161" max-vertical-offset="8772">
<caret line="21" column="49" selection-start-line="21" selection-start-column="49" selection-end-line="21" selection-end-column="49" />
<state vertical-scroll-proportion="0.0" vertical-offset="3132" max-vertical-offset="4845">
<caret line="205" column="0" selection-start-line="205" selection-start-column="0" selection-end-line="205" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tradebox.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="871" max-vertical-offset="1275">
<caret line="59" column="0" selection-start-line="59" selection-start-column="0" selection-end-line="59" selection-end-column="0" />
<folding>
<element signature="e#21#32#0" expanded="true" />
<element signature="e#22#53#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/inventory.py">
<entry file="file://$PROJECT_DIR$/sserver.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.72613066" vertical-offset="0" max-vertical-offset="408">
<caret line="17" column="58" selection-start-line="17" selection-start-column="58" selection-end-line="17" selection-end-column="58" />
<state vertical-scroll-proportion="0.0" vertical-offset="157" max-vertical-offset="1921">
<caret line="21" column="0" selection-start-line="21" selection-start-column="0" selection-end-line="21" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/sconnectionhandler.py">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.51428574" vertical-offset="1349" max-vertical-offset="8806">
<caret line="91" column="40" selection-start-line="91" selection-start-column="40" selection-end-line="91" selection-end-column="40" />
<folding>
<element signature="e#21#32#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>
\ No newline at end of file
......@@ -54,7 +54,7 @@ class Market:
@staticmethod
def exist(token):
return Market.__market.find_one_and_replace({'offer_token': token}, {'availability': False}) != None
return Market.__market.find({'offer_token': token}, {'availability': False}) != None
@staticmethod
def dirty(item):
......
......@@ -98,7 +98,7 @@ class ConnectionHandler:
elif (method == 'sendaccept'):
self.handle_sendaccept(data.get('token',''),data.get('offer_token',''))
elif (method == 'accept'):
self.handle_accept(data.get('token',''))
self.handle_accept(data.get('offer_token',''))
elif (method == 'fetchitem'):
self.handle_fetchitem(data.get('token',''),data.get('offer_token',''))
elif (method == 'canceloffer'):
......@@ -323,6 +323,7 @@ class ConnectionHandler:
# invoke accept
def handle_accept(self,offer_token):
data = ''
print("woi "+offer_token)
if (Tradebox.exist(offer_token)):
offer = Tradebox.find_offer_id(offer_token)
if offer.availability:
......@@ -343,6 +344,7 @@ class ConnectionHandler:
def handle_sendaccept(self, token, offer_token):
data = ''
print(token+' '+offer_token)
if (not Market.exist(offer_token)):
data = json.dumps({'status': 'fail', 'description': 'offer cannot be found'})
else:
......
......@@ -57,7 +57,7 @@ class Tradebox():
@staticmethod
def exist(token):
return Tradebox.__market.find_one({'_id': ObjectId(token)}) != None
return Tradebox.__market.find({'_id': ObjectId(token)}).count() > 0
if __name__ == '__main__':
# MongoClient('localhost', 27017)['sister'].create_collection('tradebox')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment