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
1=== modified file 'cheers/datamodel.py'
2--- cheers/datamodel.py 2010-11-07 14:49:24 +0000
3+++ cheers/datamodel.py 2010-11-30 20:13:59 +0000
4@@ -32,8 +32,7 @@
5 "stockicon",
6 "application",
7 "title",
8- "description",
9- "private_application_annotations"
10+ "description"
11 ]
12
13 TROPHY_SET_KEYS = [
14
15=== modified file 'cheers/datastore.py'
16--- cheers/datastore.py 2010-11-14 18:54:38 +0000
17+++ cheers/datastore.py 2010-11-30 20:13:59 +0000
18@@ -37,8 +37,16 @@
19
20 def __init__(self):
21 self.database = CouchDatabase(config.desktopcouch_db, create=True)
22- self.trophy_view = 'function(doc) { emit(doc.record_type, doc); }'
23- self.trophy_sets_view = 'function(doc) { emit(doc.record_type, doc); }'
24+ self.trophy_view = """function(doc) {
25+ if (doc.record_type == 'http://cheers-project.com/records/Trophy')
26+ {
27+ emit(doc.record_type, doc); }
28+ }"""
29+ self.trophy_sets_view = """function(doc) {
30+ if (doc.record_type == 'http://cheers-project.com/records/TrophySet')
31+ {
32+ emit(doc.record_type, doc); }
33+ }"""
34 self.single_trophy_view = 'function(doc) { emit([doc.record_type, doc.id], doc); }'
35 self.database.add_view("trophies", self.trophy_view, None, "cheers")
36 self.database.add_view("trophy_sets", self.trophy_sets_view, None, "cheers")
37@@ -57,8 +65,9 @@
38 #FIXME: There must be a more elegant way of doing this
39 results = self.database.execute_view(rec_type, "cheers")
40 for rec in results:
41- if not ids or rec["value"]["id"] in ids:
42- yield rec
43+ print rec
44+ if not ids or rec["value"]["id"] in ids:
45+ yield rec
46
47 def get_trophies(self, ids=None):
48 """ Get all the trophies registered in cheers """
49@@ -75,11 +84,12 @@
50 rec["value"]["private_application_annotations"]["cheers"]["awarded"]:
51 yield rec["value"]
52
53- def get_sets(self, ids):
54+ def get_sets(self, ids=None):
55 """ Get all the trophies registered in cheers """
56 #FIXME: There must be a more elegant way of doing this
57+ print "***************"
58 for rec in self._get_records("trophy_sets", ids):
59- yield rec["value"]
60+ yield rec["value"]["id"]
61
62 def delete_trophy(self, id):
63 """ Delete the trophy for the provided id """
64
65=== modified file 'cheers/logic.py'
66--- cheers/logic.py 2010-11-14 19:08:30 +0000
67+++ cheers/logic.py 2010-11-30 20:13:59 +0000
68@@ -109,6 +109,7 @@
69 return set(trophy.keys()) == set(datamodel.TROPHY_KEYS)
70
71 def _is_trophy_set_valid(self, trophy_set):
72+ print trophy_set.keys()
73 return set(trophy_set.keys()) == set(datamodel.TROPHY_SET_KEYS)
74
75 def get_trophy(self, id):
76@@ -125,9 +126,10 @@
77 trophy_list = self.__store.get_awarded_trophies()
78 return [datamodel.TrophyDBus(trophy) for trophy in trophy_list]
79
80- def get_sets(self, ids):
81+ def get_sets(self):
82 """ Get all the trophy sets in cheers """
83- pass
84+ return [i for i in self.__store.get_sets()]
85+
86
87 def delete_trophy(self, id):
88 """ Delete the trophy for the provided id """
89
90=== modified file 'cheers/server.py'
91--- cheers/server.py 2010-11-14 19:08:30 +0000
92+++ cheers/server.py 2010-11-30 20:13:59 +0000
93@@ -60,11 +60,10 @@
94
95 return self.logic.get_trophies()
96
97- @dbus.service.method(config.CHEERS_BUS_NAME)
98- def GetSet(self, setid_list):
99+ @dbus.service.method(config.CHEERS_BUS_NAME, out_signature='as')
100+ def GetSets(self):
101 """ Get the list of all the trophy sets available in cheers """
102-
103- return self.logic.get_sets(setid_list)
104+ return self.logic.get_sets()
105
106 @dbus.service.method(config.CHEERS_BUS_NAME, out_signature='a(saasaasssssb)')
107 def GetAwardedTrophies(self):
108
109=== modified file 'samples/valid.set'
110--- samples/valid.set 2010-11-05 15:21:41 +0000
111+++ samples/valid.set 2010-11-30 20:13:59 +0000
112@@ -13,3 +13,4 @@
113 "fr-fr": "Un Set des Trophies pour les grandes"
114 }
115 }
116+
117
118=== added file 'samples/valid.trophy'
119--- samples/valid.trophy 1970-01-01 00:00:00 +0000
120+++ samples/valid.trophy 2010-11-30 20:13:59 +0000
121@@ -0,0 +1,17 @@
122+{
123+ "record_type": "http://cheersproject.example.org/records/trophy",
124+ "id": "some-id-for-trophy",
125+ "trophyset": "my-great-trophy-set",
126+ "trophyicon": "gtk-info",
127+ "stockicon": "gtk-info",
128+ "application": "application://banshee.desktop",
129+ "title": {
130+ "default": "My Great Trophy",
131+ "fr-fr": "Mon Trophie a la Magnifique"
132+ },
133+ "description": {
134+ "default": "You must be really great! That's why you've got this trophy.",
135+ "fr-fr": "Vous êtes tres magnifique!"
136+ }
137+}
138+

Subscribers

People subscribed via source and target branches