Merge lp:~josernestodavila/pizzabashlog/fix-608368 into lp:pizzabashlog

Proposed by José Ernesto Dávila Pantoja
Status: Merged
Approved by: José Ernesto Dávila Pantoja
Approved revision: 38
Merged at revision: 31
Proposed branch: lp:~josernestodavila/pizzabashlog/fix-608368
Merge into: lp:pizzabashlog
Diff against target: 434 lines (+298/-9)
4 files modified
bin/pizzabashlog (+224/-2)
data/ui/PizzabashlogWindow.ui (+24/-0)
data/ui/SaveDialog.ui (+33/-6)
pizzabashlog/SaveDialog.py (+17/-1)
To merge this branch: bzr merge lp:~josernestodavila/pizzabashlog/fix-608368
Reviewer Review Type Date Requested Status
José Ernesto Dávila Pantoja Pending
Review via email: mp+30604@code.launchpad.net

Commit message

FIXES (LP: #608368)

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 '.quickly' (properties changed: -x to +x)
2=== modified file 'bin/pizzabashlog'
3--- bin/pizzabashlog 2010-07-13 03:19:30 +0000
4+++ bin/pizzabashlog 2010-07-22 04:09:44 +0000
5@@ -101,6 +101,11 @@
6 if not self.database.view_exists("asistencia_mensual_distro", "pizzabashlog"):
7 viewfn = 'function (doc){ emit([doc.mes, doc.distro], doc);}'
8 self.database.add_view("asistencia_mensual_distro", viewfn, None, "pizzabashlog")
9+
10+ # Crear un view para obtener la asistencia del mes por genero
11+ if not self.database.view_exists("asistencia_mensual_genero", "pizzabashlog"):
12+ viewfn = 'function (doc){emit([doc.mes, doc.genero], doc);}'
13+ self.database.add_view("asistencia_mensual_genero", viewfn, None, "pizzabashlog")
14
15 # Obtener los registros del mes actual
16 results = self.database.execute_view("asistencia_mensual","pizzabashlog")
17@@ -179,6 +184,7 @@
18
19 name = saver.get_name
20 email = saver.get_email
21+ genero = saver.get_genero
22 distro = saver.get_distro
23 month = date.today().month
24 origen = saver.get_origen
25@@ -189,7 +195,7 @@
26
27 record_type = "http://people.ubuntu.com/~josernestodavila/couch/PizzaBashLogDoc"
28 new_record = Record({"nombre": name,
29- "email": email, "distro": distro, "mes": month,
30+ "email": email, "genero":genero, "distro": distro, "mes": month,
31 "origen": origen}, record_type)
32
33 self.database.put_record(new_record)
34@@ -315,6 +321,59 @@
35 imageURI)
36 n.show()
37
38+ def email_genero(self, widget, data=None):
39+ """ email_genero - export al the female gender emails for the current month to a csv file
40+ """
41+ this_month = date.today().month
42+
43+ results = self.database.execute_view("asistencia_mensual_genero", "pizzabashlog")
44+
45+ if len(results[[this_month, 'Femenino']]) <= 0:
46+ pynotify.init('PizzaBashLog')
47+ imageURI = 'file://' + getdatapath() + '/media/logo.png'
48+ n = pynotify.Notification("Pizzabashlog",
49+ "No existen registros para exportar",
50+ imageURI)
51+ n.show()
52+ return
53+
54+ chooser = gtk.FileChooserDialog("PizzaBashLog - Guardar Archivo",
55+ self,
56+ gtk.FILE_CHOOSER_ACTION_SAVE,
57+ (gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,
58+ gtk.STOCK_OPEN,gtk.RESPONSE_OK))
59+ chooser.set_default_response(gtk.RESPONSE_OK)
60+
61+ filter = gtk.FileFilter()
62+ filter.set_name("Archivos CSV")
63+ filter.add_pattern("*.csv")
64+ chooser.add_filter(filter)
65+ chooser.set_current_name('ListadoFemenino.csv')
66+
67+ response = chooser.run()
68+
69+ if response != gtk.RESPONSE_OK:
70+ return
71+
72+ filename = chooser.get_filename()
73+ chooser.destroy()
74+
75+ f = open(filename,"w")
76+
77+ for result in results[[this_month, 'Femenino']]:
78+ f.writelines(result.value['email'] + '\n')
79+
80+ f.close()
81+
82+ pynotify.init('PizzaBashLog')
83+ imageURI = 'file://' + getdatapath() + '/media/logo.png'
84+ logging.debug("GetDataPath: " + getdatapath())
85+ logging.debug(imageURI)
86+ n = pynotify.Notification("Pizzabashlog",
87+ "Se han exportados los emails al archivo " + filename,
88+ imageURI)
89+ n.show()
90+
91 def view_asist_distro(self, widget, data=None):
92 """view_asist_distro - creates a Pie Plot graph showing the distros used by the attendance
93 """
94@@ -614,7 +673,170 @@
95 logging.debug(filename)
96 dialog.run()
97 dialog.destroy()
98-
99+
100+ def view_asist_genero(self, widget, data=None):
101+ """view_asist_genero - Genera un gráfico de pastel con la proporción de asistencia por género
102+ """
103+ data = {}
104+ this_month = date.today().month
105+
106+ results = self.database.execute_view("asistencia_mensual", "pizzabashlog")
107+
108+ if len(results[[this_month]]) <= 0:
109+ pynotify.init('PizzaBashLog')
110+ imageURI = 'file://' + getdatapath() + '/media/logo.png'
111+ n = pynotify.Notification("Pizzabashlog",
112+ "No existen registros para generar el gráfico",
113+ imageURI)
114+ n.show()
115+ return
116+
117+ # Prepare data to be plotted
118+ for r in results[[this_month]]:
119+ key = r.value['genero']
120+ if not key in data:
121+ data[key] = 1
122+ else:
123+ data[key] += 1
124+
125+ home_dir = os.path.expanduser("~")
126+ filename = home_dir + '/PBLAsistGenero.png'
127+
128+ # Generate the graph
129+ surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 640, 480)
130+
131+ """dataset = (
132+ ('Femenino', [data['Femenino']]),
133+ ('Masculino', [data['Masculino']]),
134+ )"""
135+ dataset = [(v, [[0, data[v]]]) for v in data]
136+
137+ options = {
138+ 'axis': {
139+ 'x': {
140+ 'ticks': [dict(v=i, label=d) for i, d in enumerate(data)],
141+ }
142+ },
143+ 'background': {
144+ 'hide': False,
145+ },
146+ 'colorScheme': {
147+ 'name': 'fixed',
148+ 'args': {
149+ 'colors': ('#3C6EB4','#DD1155',),
150+ },
151+ },
152+ 'padding': {
153+ 'left': 10,
154+ 'right': 10,
155+ 'top': 0,
156+ 'bottom': 0,
157+ },
158+ 'legend': {
159+ 'hide': False,
160+ }
161+ }
162+
163+ chart = pycha.pie.PieChart(surface, options)
164+ chart.addDataset(dataset)
165+ chart.render()
166+
167+ surface.write_to_png(filename)
168+ # End Generate the graph
169+
170+ # Show the pie_plot image in a dialog
171+ dialog = ViewgraphDialog.ViewgraphDialog()
172+ dialog.set_graph = filename
173+ logging.debug(filename)
174+ dialog.run()
175+ dialog.destroy()
176+
177+ def view_asist_mensual_genero(self, widget, data=None):
178+ """view_asist_mensual_genero - shows a dot_line graph with the monthly asistance by gender"""
179+ data = {}
180+ legend = []
181+ this_month = date.today().month
182+ this_year = str(date.today().year)
183+ meses = ('', 'ene', 'feb', 'mar', 'abr', 'may', 'jun', 'jul', 'ago', 'sep', 'oct', 'nov', 'dic')
184+ generos = ('Femenino', 'Masculino')
185+
186+ results = self.database.execute_view("asistencia_mensual_genero", "pizzabashlog")
187+
188+ if len(results) <= 0:
189+ pynotify.init('PizzaBashLog')
190+ imageURI = 'file://' + getdatapath() + '/media/logo.png'
191+ n = pynotify.Notification("Pizzabashlog",
192+ "No existen registros para generar el gráfico",
193+ imageURI)
194+ n.show()
195+ return
196+
197+ for m in range(1, this_month + 1):
198+ for k in generos:
199+ if k not in data:
200+ data[k] = [len(results[[m, k]])]
201+ else:
202+ data[k].append(len(results[[m, k]]))
203+ legend.append(meses[m] + '/' + this_year)
204+
205+ logging.debug(data)
206+
207+ home_dir = os.path.expanduser("~")
208+ filename = home_dir + '/PBLAsistenciaMensualGenero.png'
209+
210+ # Generate graph
211+ surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 640, 480)
212+
213+ dataset = (
214+ ('Femenino', [(i, l) for i, l in enumerate(data['Femenino'])]),
215+ ('Masculino', [(i, l) for i, l in enumerate(data['Masculino'])]),
216+ )
217+
218+ options = {
219+ 'axis': {
220+ 'x': {
221+ 'ticks': [dict(v=i, label=l) for i, l in enumerate(legend)],
222+ 'rotate': 25,
223+ },
224+ 'y': {
225+ 'tickCount': 5,
226+ 'rotate': 25,
227+ }
228+ },
229+ 'background': {
230+ 'color': '#eeeeff',
231+ 'lineColor': '#444444'
232+ },
233+ 'colorScheme': {
234+ 'name': 'fixed',
235+ 'args': {
236+ 'colors': ('#DD1155','#3C6EB4',),
237+ },
238+ },
239+ 'legend': {
240+ 'hide': False,
241+ },
242+ 'padding': {
243+ 'left': 150,
244+ 'bottom': 40,
245+ }
246+ }
247+
248+ chart = pycha.bar.VerticalBarChart(surface, options)
249+
250+ chart.addDataset(dataset)
251+ chart.render()
252+
253+ surface.write_to_png(filename)
254+ # End Generate graph
255+
256+ # Show the dot_line_plot image in a dialog
257+ dialog = ViewgraphDialog.ViewgraphDialog()
258+ dialog.set_graph = filename
259+ logging.debug(filename)
260+ dialog.run()
261+ dialog.destroy()
262+
263 def NewPizzabashlogWindow():
264 """NewPizzabashlogWindow - returns a fully instantiated
265 PizzabashlogWindow object. Use this function rather than
266
267=== modified file 'data/ui/AboutPizzabashlogDialog.ui' (properties changed: -x to +x)
268=== modified file 'data/ui/PizzabashlogWindow.ui'
269--- data/ui/PizzabashlogWindow.ui 2010-06-21 23:30:53 +0000
270+++ data/ui/PizzabashlogWindow.ui 2010-07-22 04:09:44 +0000
271@@ -64,6 +64,14 @@
272 <signal name="activate" handler="email_to_csv"/>
273 </object>
274 </child>
275+ <child>
276+ <object class="GtkMenuItem" id="menuitem11">
277+ <property name="visible">True</property>
278+ <property name="label" translatable="yes">E-Mail del Mes - G&#xE9;nero Femenino</property>
279+ <property name="use_underline">True</property>
280+ <signal name="activate" handler="email_genero"/>
281+ </object>
282+ </child>
283 </object>
284 </child>
285 </object>
286@@ -126,6 +134,22 @@
287 <signal name="activate" handler="view_asist_origen"/>
288 </object>
289 </child>
290+ <child>
291+ <object class="GtkMenuItem" id="menuitem12">
292+ <property name="visible">True</property>
293+ <property name="label" translatable="yes">Asistencia x G&#xE9;nero</property>
294+ <property name="use_underline">True</property>
295+ <signal name="activate" handler="view_asist_genero"/>
296+ </object>
297+ </child>
298+ <child>
299+ <object class="GtkMenuItem" id="menuitem13">
300+ <property name="visible">True</property>
301+ <property name="label" translatable="yes">Asistencia Mensual x G&#xE9;nero</property>
302+ <property name="use_underline">True</property>
303+ <signal name="activate" handler="view_asist_mensual_genero"/>
304+ </object>
305+ </child>
306 </object>
307 </child>
308 </object>
309
310=== modified file 'data/ui/SaveDialog.ui'
311--- data/ui/SaveDialog.ui 2010-04-21 03:35:37 +0000
312+++ data/ui/SaveDialog.ui 2010-07-22 04:09:44 +0000
313@@ -36,7 +36,7 @@
314 </object>
315 <packing>
316 <property name="expand">False</property>
317- <property name="padding">47</property>
318+ <property name="padding">43</property>
319 <property name="position">0</property>
320 </packing>
321 </child>
322@@ -66,7 +66,7 @@
323 </object>
324 <packing>
325 <property name="expand">False</property>
326- <property name="padding">52</property>
327+ <property name="padding">50</property>
328 <property name="position">0</property>
329 </packing>
330 </child>
331@@ -90,13 +90,40 @@
332 <object class="GtkHBox" id="hbox3">
333 <property name="visible">True</property>
334 <child>
335+ <object class="GtkLabel" id="label6">
336+ <property name="visible">True</property>
337+ <property name="label" translatable="yes">G&#xE9;nero:</property>
338+ </object>
339+ <packing>
340+ <property name="expand">False</property>
341+ <property name="padding">46</property>
342+ <property name="position">0</property>
343+ </packing>
344+ </child>
345+ <child>
346+ <object class="GtkComboBox" id="cboGenero">
347+ <property name="visible">True</property>
348+ </object>
349+ <packing>
350+ <property name="position">1</property>
351+ </packing>
352+ </child>
353+ </object>
354+ <packing>
355+ <property name="position">3</property>
356+ </packing>
357+ </child>
358+ <child>
359+ <object class="GtkHBox" id="hbox4">
360+ <property name="visible">True</property>
361+ <child>
362 <object class="GtkLabel" id="label4">
363 <property name="visible">True</property>
364 <property name="label" translatable="yes">Distribuci&#xF3;n:</property>
365 </object>
366 <packing>
367 <property name="expand">False</property>
368- <property name="padding">34</property>
369+ <property name="padding">33</property>
370 <property name="position">0</property>
371 </packing>
372 </child>
373@@ -110,11 +137,11 @@
374 </child>
375 </object>
376 <packing>
377- <property name="position">3</property>
378+ <property name="position">4</property>
379 </packing>
380 </child>
381 <child>
382- <object class="GtkHBox" id="hbox4">
383+ <object class="GtkHBox" id="hbox5">
384 <property name="visible">True</property>
385 <child>
386 <object class="GtkLabel" id="label5">
387@@ -136,7 +163,7 @@
388 </child>
389 </object>
390 <packing>
391- <property name="position">4</property>
392+ <property name="position">5</property>
393 </packing>
394 </child>
395 </object>
396
397=== modified file 'debian/control' (properties changed: -x to +x)
398=== modified file 'pizzabashlog/SaveDialog.py'
399--- pizzabashlog/SaveDialog.py 2010-04-21 03:35:37 +0000
400+++ pizzabashlog/SaveDialog.py 2010-07-22 04:09:44 +0000
401@@ -78,7 +78,19 @@
402 self.combo1.pack_start(cell1, True)
403 self.combo1.add_attribute(cell1, 'text', 0)
404 self.combo1.set_active(0)
405-
406+
407+ #Agregar a cboGenero los géneros Masculino y Femenino
408+ lstGenero = gtk.ListStore(gobject.TYPE_STRING)
409+ lstGenero.append(['Femenino'])
410+ lstGenero.append(['Masculino'])
411+
412+ self.cboGenero = self.builder.get_object("cboGenero")
413+ self.cboGenero.set_model(lstGenero)
414+ cell2 = gtk.CellRendererText()
415+ self.cboGenero.pack_start(cell2, True)
416+ self.cboGenero.add_attribute(cell2, 'text', 0)
417+ self.cboGenero.set_active(0)
418+
419 def ok(self, widget, data=None):
420 """ok - The user has elected to save the changes.
421 Called before the dialog returns gtk.RESONSE_OK from run().
422@@ -120,6 +132,10 @@
423 return self.builder.get_object("entry2").get_text()
424
425 @property
426+ def get_genero(self):
427+ return self.builder.get_object("cboGenero").get_active_text()
428+
429+ @property
430 def get_distro(self):
431 return self.builder.get_object("combobox1").get_active_text()
432
433
434=== modified file 'setup.py' (properties changed: -x to +x)

Subscribers

People subscribed via source and target branches