Commits

anshik committed ef5ee8f

ten meetings works good

  • Participants
  • Parent commits b0fcf5c

Comments (0)

Files changed (1)

File src/main_window.py

 # -*- coding: utf-8 -*-
-from datetime import time
+from datetime import time, datetime
 
 from time import sleep
 #python-qt4-sql
-from PyQt4 import QtCore, QtGui, QtSql, QtXml
+from PyQt4 import QtCore, QtGui, QtSql
 #import sys
 #
 #
         if 0 == page:   # table
             self.model.setTable('testdb_meetings_meeting')
             self.model.setRelation(2, QtSql.QSqlRelation("testdb_meetings_meetingtype", "id", "type"))
+            self.model.setSort(5, 0)
             self.update_model()
         elif page == 1:           # calendar
             pass
         self.model.select()
 
     def ten_meetings_clicked(self):
-        #TODO: add filter 10 meetings
+
+        self.model.setSort(5, 0) # sorts by since_date by growing
+        self.model.select()
+
 
         table_fields = ['name','type_id','place','since_date','to_date']
         test_input = []
+
         for i in xrange(self.model.rowCount()):
-            record = self.model.record(i)
-            cur_rec = []
-            for j in xrange(1,6):
-                cur_rec.append((table_fields[j-1], unicode(record.value(j).toString())))
-            test_input.append(('meeting',cur_rec))
+            meeting_date = datetime.strptime(unicode(self.model.record(i).value(5).toString()), "%Y-%m-%d %H:%M:%S")
+            if datetime.today() < meeting_date:
+                record = self.model.record(i)
+                cur_rec = []
+                for j in xrange(1,6):
+                    cur_rec.append((table_fields[j-1], unicode(record.value(j).toString())))
+                test_input.append(('meeting',cur_rec))
 
-        out2 = ('meetings',test_input[-10:]) #3 yet
+        out2 = ('meetings',test_input[:10])
 
         result = pyfo(out2, pretty=True, prolog=True, encoding='utf-8')