Merge lp:~manishsinha/cheers/fixed-getsets into lp:cheers

Status: Merged
Merged at revision: 22
Proposed branch: lp:~manishsinha/cheers/fixed-getsets
Merge into: lp:cheers
Diff against target: 138 lines (+42/-14)
6 files modified
cheers/datamodel.py (+1/-2)
cheers/datastore.py (+16/-6)
cheers/logic.py (+4/-2)
cheers/server.py (+3/-4)
samples/valid.set (+1/-0)
samples/valid.trophy (+17/-0)
To merge this branch: bzr merge lp:~manishsinha/cheers/fixed-getsets
Reviewer Review Type Date Requested Status
Cheers Pending
Review via email: mp+42300@code.launchpad.net

Description of the change

Fixed the GetSets method problem

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cheers/datamodel.py'
--- cheers/datamodel.py 2010-11-07 14:49:24 +0000
+++ cheers/datamodel.py 2010-11-30 20:13:59 +0000
@@ -32,8 +32,7 @@
32 "stockicon",32 "stockicon",
33 "application",33 "application",
34 "title",34 "title",
35 "description",35 "description"
36 "private_application_annotations"
37 ]36 ]
3837
39TROPHY_SET_KEYS = [38TROPHY_SET_KEYS = [
4039
=== modified file 'cheers/datastore.py'
--- cheers/datastore.py 2010-11-14 18:54:38 +0000
+++ cheers/datastore.py 2010-11-30 20:13:59 +0000
@@ -37,8 +37,16 @@
37 37
38 def __init__(self):38 def __init__(self):
39 self.database = CouchDatabase(config.desktopcouch_db, create=True)39 self.database = CouchDatabase(config.desktopcouch_db, create=True)
40 self.trophy_view = 'function(doc) { emit(doc.record_type, doc); }'40 self.trophy_view = """function(doc) {
41 self.trophy_sets_view = 'function(doc) { emit(doc.record_type, doc); }'41 if (doc.record_type == 'http://cheers-project.com/records/Trophy')
42 {
43 emit(doc.record_type, doc); }
44 }"""
45 self.trophy_sets_view = """function(doc) {
46 if (doc.record_type == 'http://cheers-project.com/records/TrophySet')
47 {
48 emit(doc.record_type, doc); }
49 }"""
42 self.single_trophy_view = 'function(doc) { emit([doc.record_type, doc.id], doc); }'50 self.single_trophy_view = 'function(doc) { emit([doc.record_type, doc.id], doc); }'
43 self.database.add_view("trophies", self.trophy_view, None, "cheers")51 self.database.add_view("trophies", self.trophy_view, None, "cheers")
44 self.database.add_view("trophy_sets", self.trophy_sets_view, None, "cheers")52 self.database.add_view("trophy_sets", self.trophy_sets_view, None, "cheers")
@@ -57,8 +65,9 @@
57 #FIXME: There must be a more elegant way of doing this65 #FIXME: There must be a more elegant way of doing this
58 results = self.database.execute_view(rec_type, "cheers")66 results = self.database.execute_view(rec_type, "cheers")
59 for rec in results:67 for rec in results:
60 if not ids or rec["value"]["id"] in ids:68 print rec
61 yield rec69 if not ids or rec["value"]["id"] in ids:
70 yield rec
62 71
63 def get_trophies(self, ids=None):72 def get_trophies(self, ids=None):
64 """ Get all the trophies registered in cheers """73 """ Get all the trophies registered in cheers """
@@ -75,11 +84,12 @@
75 rec["value"]["private_application_annotations"]["cheers"]["awarded"]:84 rec["value"]["private_application_annotations"]["cheers"]["awarded"]:
76 yield rec["value"]85 yield rec["value"]
7786
78 def get_sets(self, ids):87 def get_sets(self, ids=None):
79 """ Get all the trophies registered in cheers """88 """ Get all the trophies registered in cheers """
80 #FIXME: There must be a more elegant way of doing this89 #FIXME: There must be a more elegant way of doing this
90 print "***************"
81 for rec in self._get_records("trophy_sets", ids):91 for rec in self._get_records("trophy_sets", ids):
82 yield rec["value"]92 yield rec["value"]["id"]
8393
84 def delete_trophy(self, id):94 def delete_trophy(self, id):
85 """ Delete the trophy for the provided id """95 """ Delete the trophy for the provided id """
8696
=== modified file 'cheers/logic.py'
--- cheers/logic.py 2010-11-14 19:08:30 +0000
+++ cheers/logic.py 2010-11-30 20:13:59 +0000
@@ -109,6 +109,7 @@
109 return set(trophy.keys()) == set(datamodel.TROPHY_KEYS)109 return set(trophy.keys()) == set(datamodel.TROPHY_KEYS)
110 110
111 def _is_trophy_set_valid(self, trophy_set):111 def _is_trophy_set_valid(self, trophy_set):
112 print trophy_set.keys()
112 return set(trophy_set.keys()) == set(datamodel.TROPHY_SET_KEYS)113 return set(trophy_set.keys()) == set(datamodel.TROPHY_SET_KEYS)
113 114
114 def get_trophy(self, id):115 def get_trophy(self, id):
@@ -125,9 +126,10 @@
125 trophy_list = self.__store.get_awarded_trophies()126 trophy_list = self.__store.get_awarded_trophies()
126 return [datamodel.TrophyDBus(trophy) for trophy in trophy_list]127 return [datamodel.TrophyDBus(trophy) for trophy in trophy_list]
127128
128 def get_sets(self, ids):129 def get_sets(self):
129 """ Get all the trophy sets in cheers """130 """ Get all the trophy sets in cheers """
130 pass131 return [i for i in self.__store.get_sets()]
132
131133
132 def delete_trophy(self, id):134 def delete_trophy(self, id):
133 """ Delete the trophy for the provided id """135 """ Delete the trophy for the provided id """
134136
=== modified file 'cheers/server.py'
--- cheers/server.py 2010-11-14 19:08:30 +0000
+++ cheers/server.py 2010-11-30 20:13:59 +0000
@@ -60,11 +60,10 @@
6060
61 return self.logic.get_trophies()61 return self.logic.get_trophies()
62 62
63 @dbus.service.method(config.CHEERS_BUS_NAME)63 @dbus.service.method(config.CHEERS_BUS_NAME, out_signature='as')
64 def GetSet(self, setid_list):64 def GetSets(self):
65 """ Get the list of all the trophy sets available in cheers """65 """ Get the list of all the trophy sets available in cheers """
6666 return self.logic.get_sets()
67 return self.logic.get_sets(setid_list)
68 67
69 @dbus.service.method(config.CHEERS_BUS_NAME, out_signature='a(saasaasssssb)')68 @dbus.service.method(config.CHEERS_BUS_NAME, out_signature='a(saasaasssssb)')
70 def GetAwardedTrophies(self):69 def GetAwardedTrophies(self):
7170
=== modified file 'samples/valid.set'
--- samples/valid.set 2010-11-05 15:21:41 +0000
+++ samples/valid.set 2010-11-30 20:13:59 +0000
@@ -13,3 +13,4 @@
13 "fr-fr": "Un Set des Trophies pour les grandes"13 "fr-fr": "Un Set des Trophies pour les grandes"
14 }14 }
15}15}
16
1617
=== added file 'samples/valid.trophy'
--- samples/valid.trophy 1970-01-01 00:00:00 +0000
+++ samples/valid.trophy 2010-11-30 20:13:59 +0000
@@ -0,0 +1,17 @@
1{
2 "record_type": "http://cheersproject.example.org/records/trophy",
3 "id": "some-id-for-trophy",
4 "trophyset": "my-great-trophy-set",
5 "trophyicon": "gtk-info",
6 "stockicon": "gtk-info",
7 "application": "application://banshee.desktop",
8 "title": {
9 "default": "My Great Trophy",
10 "fr-fr": "Mon Trophie a la Magnifique"
11 },
12 "description": {
13 "default": "You must be really great! That's why you've got this trophy.",
14 "fr-fr": "Vous êtes tres magnifique!"
15 }
16}
17

Subscribers

People subscribed via source and target branches