[Openlanhouse-development] SF.net SVN: openlanhouse:[308] trunk/openlh-server
Status: Pre-Alpha
Brought to you by:
n3rd3x
|
From: <n3...@us...> - 2008-10-16 20:03:35
|
Revision: 308
http://openlanhouse.svn.sourceforge.net/openlanhouse/?rev=308&view=rev
Author: n3rd3x
Date: 2008-10-16 20:03:22 +0000 (Thu, 16 Oct 2008)
Log Message:
-----------
Added the avatar support
Modified Paths:
--------------
trunk/openlh-server/data/ui/add_user.ui
trunk/openlh-server/data/ui/edit_user.ui
trunk/openlh-server/src/OpenlhServer/globals.py
trunk/openlh-server/src/OpenlhServer/plugins/example/__init__.py
trunk/openlh-server/src/OpenlhServer/ui/dialogs.py
trunk/openlh-server/src/OpenlhServer/ui/main.py
trunk/openlh-server/src/OpenlhServer/utils.py
trunk/openlh-server/src/openlh-server
Modified: trunk/openlh-server/data/ui/add_user.ui
===================================================================
--- trunk/openlh-server/data/ui/add_user.ui 2008-10-15 20:07:49 UTC (rev 307)
+++ trunk/openlh-server/data/ui/add_user.ui 2008-10-16 20:03:22 UTC (rev 308)
@@ -47,6 +47,29 @@
<placeholder/>
</child>
<child>
+ <object class="GtkButton" id="user_avatar_button">
+ <property name="visible">True</property>
+ <signal handler="on_user_avatar_clicked" name="clicked"/>
+ <child>
+ <object class="GtkImage" id="user_avatar_image">
+ <property name="visible">True</property>
+ <property name="width-request">64</property>
+ <property name="height-request">94</property>
+ <property name="icon-name">stock_person</property>
+ <property name="icon-size">6</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkImage" id="nick_status_image">
<property name="width_request">15</property>
<property name="height_request">15</property>
@@ -55,8 +78,8 @@
<property name="icon_size">2</property>
</object>
<packing>
- <property name="left_attach">4</property>
- <property name="right_attach">5</property>
+ <property name="left_attach">5</property>
+ <property name="right_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -71,8 +94,8 @@
<signal handler="on_nick_insert_text" name="insert_text"/>
</object>
<packing>
- <property name="left_attach">3</property>
- <property name="right_attach">4</property>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
</packing>
</child>
<child>
@@ -86,8 +109,8 @@
<property name="mnemonic_widget">nick</property>
</object>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
@@ -102,8 +125,8 @@
<property name="use_underline">True</property>
</object>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
@@ -123,6 +146,8 @@
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -136,8 +161,8 @@
<property name="width_chars">20</property>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">GTK_FILL</property>
@@ -154,6 +179,8 @@
<property name="mnemonic_widget">full_name</property>
</object>
<packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
@@ -167,8 +194,8 @@
<property name="width_chars">20</property>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
@@ -184,8 +211,8 @@
<property name="mnemonic_widget">identity</property>
</object>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
@@ -201,8 +228,8 @@
<property name="width_chars">14</property>
</object>
<packing>
- <property name="left_attach">3</property>
- <property name="right_attach">4</property>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"/>
@@ -220,6 +247,8 @@
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
@@ -233,8 +262,8 @@
<property name="width_chars">20</property>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
@@ -811,7 +840,6 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</object>
Modified: trunk/openlh-server/data/ui/edit_user.ui
===================================================================
--- trunk/openlh-server/data/ui/edit_user.ui 2008-10-15 20:07:49 UTC (rev 307)
+++ trunk/openlh-server/data/ui/edit_user.ui 2008-10-16 20:03:22 UTC (rev 308)
@@ -41,6 +41,29 @@
<placeholder/>
</child>
<child>
+ <object class="GtkButton" id="user_avatar_button">
+ <property name="visible">True</property>
+ <signal handler="on_user_avatar_clicked" name="clicked"/>
+ <child>
+ <object class="GtkImage" id="user_avatar_image">
+ <property name="visible">True</property>
+ <property name="width-request">64</property>
+ <property name="height-request">94</property>
+ <property name="icon-name">stock_person</property>
+ <property name="icon-size">6</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkImage" id="nick_status_image">
<property name="width_request">15</property>
<property name="height_request">15</property>
@@ -49,8 +72,8 @@
<property name="icon_size">2</property>
</object>
<packing>
- <property name="left_attach">4</property>
- <property name="right_attach">5</property>
+ <property name="left_attach">5</property>
+ <property name="right_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -64,8 +87,8 @@
<property name="width_chars">20</property>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
@@ -81,10 +104,12 @@
<property name="mnemonic_widget">phone</property>
</object>
<packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_EXPAND</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -96,8 +121,8 @@
<property name="width_chars">14</property>
</object>
<packing>
- <property name="left_attach">3</property>
- <property name="right_attach">4</property>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"/>
@@ -114,8 +139,8 @@
<property name="mnemonic_widget">identity</property>
</object>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
@@ -133,8 +158,8 @@
<property name="mnemonic_widget">nick</property>
</object>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
@@ -149,8 +174,8 @@
<signal handler="on_nick_insert_text" name="insert_text"/>
</object>
<packing>
- <property name="left_attach">3</property>
- <property name="right_attach">4</property>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
<property name="y_options"/>
</packing>
</child>
@@ -163,8 +188,8 @@
<property name="width_chars">20</property>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
@@ -179,6 +204,8 @@
<property name="mnemonic_widget">full_name</property>
</object>
<packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -192,8 +219,8 @@
<property name="width_chars">20</property>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">GTK_FILL</property>
@@ -210,6 +237,8 @@
<property name="mnemonic_widget">email</property>
</object>
<packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
@@ -226,8 +255,8 @@
<property name="use_underline">True</property>
</object>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
@@ -547,12 +576,12 @@
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
- <object class="GtkButton" id="cancel_bnt">
+ <object class="GtkButton" id="help_bnt">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">gtk-cancel</property>
+ <property name="label" translatable="yes">gtk-help</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -560,6 +589,16 @@
</packing>
</child>
<child>
+ <object class="GtkButton" id="cancel_bnt">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
<object class="GtkButton" id="ok_bnt">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -568,9 +607,6 @@
<property name="label" translatable="yes">gtk-ok</property>
<property name="use_stock">True</property>
</object>
- <packing>
- <property name="position">1</property>
- </packing>
</child>
</object>
<packing>
Modified: trunk/openlh-server/src/OpenlhServer/globals.py
===================================================================
--- trunk/openlh-server/src/OpenlhServer/globals.py 2008-10-15 20:07:49 UTC (rev 307)
+++ trunk/openlh-server/src/OpenlhServer/globals.py 2008-10-16 20:03:22 UTC (rev 308)
@@ -48,6 +48,7 @@
CERTS_PATH = ospath.join(CONFIG_PATH, 'certs')
UI_PATH = ospath.join(CUR_PATH, 'ui')
CACHE_PATH = ospath.join(CONFIG_PATH, 'cache')
+AVATARS_PATH = ospath.join(CONFIG_PATH, 'avatars')
BACKGROUND_CACHE = ospath.join(CACHE_PATH, 'wallpaper')
LOGO_CACHE = ospath.join(CACHE_PATH, 'logo')
Modified: trunk/openlh-server/src/OpenlhServer/plugins/example/__init__.py
===================================================================
--- trunk/openlh-server/src/OpenlhServer/plugins/example/__init__.py 2008-10-15 20:07:49 UTC (rev 307)
+++ trunk/openlh-server/src/OpenlhServer/plugins/example/__init__.py 2008-10-16 20:03:22 UTC (rev 308)
@@ -1,3 +1,20 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2008 Wilson Pinto J\xFAnior (N3RD3X) <n3...@gu...>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
PLUGIN_NAME = "Example"
PLUGIN_DESCRIPTION = "Plugin Example"
Modified: trunk/openlh-server/src/OpenlhServer/ui/dialogs.py
===================================================================
--- trunk/openlh-server/src/OpenlhServer/ui/dialogs.py 2008-10-15 20:07:49 UTC (rev 307)
+++ trunk/openlh-server/src/OpenlhServer/ui/dialogs.py 2008-10-16 20:03:22 UTC (rev 308)
@@ -27,6 +27,7 @@
from os import name as osname
from os import path as ospath
+from os import remove as os_remove
from time import localtime
from threading import Lock
from OpenlhServer.ui import icons, DateEdit, HourEntry
@@ -34,6 +35,7 @@
from OpenlhServer.ui.utils import color_entry
from OpenlhServer.utils import calculate_time, calculate_credit, md5_cripto, check_nick, check_name
from OpenlhServer.utils import is_in_path, execute_command, threaded, get_gtk_builder
+from OpenlhServer.utils import user_has_avatar, get_user_avatar_path
from OpenlhServer.db.models import CashFlowItem, User
GNOME_OPEN_PATH = is_in_path('gnome-open')
@@ -259,6 +261,90 @@
self.set_preview_widget_active(False)
self.use_preview = False
+class ImageChooserDialog(gtk.FileChooserDialog):
+ def __init__(self, parent=None):
+ gtk.FileChooserDialog.__init__(self, title='Choose Image',
+ parent=parent,
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN, gtk.RESPONSE_OK,
+ _("_No Image"), gtk.RESPONSE_NONE))
+
+ self.toggle = gtk.CheckButton("Preview images")
+ self.set_extra_widget(self.toggle)
+ self.toggle.set_active(True)
+ self.toggle.connect('toggled', self.toggled_cb)
+ self.toggle.show()
+ self.use_preview = True
+
+ filter = gtk.FileFilter()
+ filter.set_name(_('All files'))
+ filter.add_pattern('*')
+ self.add_filter(filter)
+
+ filter = gtk.FileFilter()
+ filter.set_name(_('Images') )
+ filter.add_mime_type('image/png')
+ filter.add_mime_type('image/jpeg')
+ filter.add_mime_type('image/gif')
+ filter.add_mime_type('image/tiff')
+ filter.add_mime_type('image/svg+xml')
+ filter.add_mime_type('image/x-xpixmap')
+ self.add_filter(filter)
+ self.set_filter(filter)
+
+ if osname == 'posix' and ospath.exists('/usr/share/pixmaps'):
+ self.add_shortcut_folder('/usr/share/pixmaps')
+
+ self.set_use_preview_label(False)
+ self.previewidget = gtk.Image()
+ self.set_preview_widget(self.previewidget)
+ self.connect("update-preview", self.update_preview_cb, self.previewidget)
+
+ def update_preview_cb(self, file_chooser, preview):
+
+ if not self.use_preview:
+ return
+
+ filename = file_chooser.get_preview_filename()
+
+ try:
+ pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(filename,
+ PREVIEW_SIZE, PREVIEW_SIZE)
+ self.previewidget.set_from_pixbuf(pixbuf)
+ self.have_preview = True
+
+ except:
+ self.have_preview = False
+
+ self.set_preview_widget_active(self.have_preview)
+ return
+
+ def toggled_cb(self, obj):
+ if obj.get_active():
+ filename = self.get_preview_filename()
+
+ try:
+ pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(filename,
+ PREVIEW_SIZE, PREVIEW_SIZE)
+ self.previewidget.set_from_pixbuf(pixbuf)
+ self.have_preview = True
+ except:
+ self.have_preview = False
+
+ self.set_preview_widget_active(self.have_preview)
+ self.use_preview = True
+
+ else:
+ self.set_preview_widget_active(False)
+ self.use_preview = False
+
+ def run(self):
+ response = gtk.FileChooserDialog.run(self)
+ file = self.get_filename()
+ self.hide()
+ return response, file
+
class user_edit:
ui_file = 'edit_user'
@@ -274,6 +360,8 @@
warns = []
faults = []
+ user_avatar = None
+
def __init__(self, users_manager, Parent=None):
self.users_manager = users_manager
@@ -288,10 +376,9 @@
self.notes = self.xml.get_object('notes')
self.address = self.xml.get_object('address')
self.cancel_bnt = self.xml.get_object('cancel_bnt')
+ self.user_avatar_button = self.xml.get_object('user_avatar_button')
+ self.user_avatar_image = self.xml.get_object('user_avatar_image')
- if self.cancel_bnt:
- self.buttonbox.set_child_secondary(self.cancel_bnt, True)
-
self.ok_bnt = self.xml.get_object('ok_bnt')
self.notesbuffer = self.notes.get_buffer()
self.addressbuffer = self.address.get_buffer()
@@ -300,7 +387,7 @@
self.xml.get_object('nick_status_image').set_from_file(None)
self.birth = DateEdit.DateEdit()
- self.table2.attach(self.birth, 3, 4, 2, 3,
+ self.table2.attach(self.birth, 4, 5, 2, 3,
xoptions=gtk.FILL, yoptions=gtk.FILL)
self.birth.show()
@@ -391,7 +478,48 @@
self._nick_timeout_id = gobject.timeout_add(timeout,
self.on_nick_changed_done)
+
+ def on_user_avatar_clicked(self, obj):
+ dlg = ImageChooserDialog()
+ response, image_file = dlg.run()
+ if response == gtk.RESPONSE_NONE:
+ self.user_avatar = None
+ self.user_avatar_image.set_from_icon_name("stock_person", 6)
+
+ #Remove Avatar File
+ if user_has_avatar(self.data['id']):
+ try:
+ os_remove(get_user_avatar_path(self.data['id']))
+ except Exception , e:
+ print str(e)
+
+
+ if response == gtk.RESPONSE_OK:
+ self.user_avatar = image_file
+
+ pixbuf = gtk.gdk.pixbuf_new_from_file(image_file)
+
+ if not pixbuf:
+ return
+
+ #Calculate resize
+ height = pixbuf.get_height()
+ width = pixbuf.get_width()
+
+ k = width / 64.0
+ l = height / 94.0
+
+ if k >= l:
+ x = 64
+ y = height / k
+ else:
+ x = width / l
+ y = 94
+
+ pixbuf = pixbuf.scale_simple(int(x), int(y), gtk.gdk.INTERP_TILES)
+ self.user_avatar_image.set_from_pixbuf(pixbuf)
+
def reset_data(self):
for key in self.input.keys():
@@ -427,6 +555,11 @@
if user.birth:
self.data['birth'] = user.birth
self.birth.set_time(map(int, self.data['birth'].split('-')))
+
+ self.data['id'] = user.id
+
+ if user_has_avatar(user.id):
+ self.user_avatar_image.set_from_file(get_user_avatar_path(user.id))
def get_data(self):
@@ -471,7 +604,21 @@
user.__setattr__(key, value)
self.users_manager.update(user)
+
+ #Avatar
+ try:
+ avatar_pixbuf = self.user_avatar_image.get_pixbuf()
+ except ValueError:
+ avatar_pixbuf = None
+
+ if self.user_avatar and avatar_pixbuf:
+ path = get_user_avatar_path(user.id)
+ try:
+ avatar_pixbuf.save(path, "jpeg", {"quality":"100"})
+ except Exception, error:
+ print error
+
self.users.destroy()
def check_obj(self, obj, name):
@@ -526,6 +673,11 @@
self.notebook = self.xml.get_object("notebook")
self.faults = ['nick', 'full_name']
+ self.help_bnt = gtk.Button(stock=gtk.STOCK_HELP)
+ self.buttonbox.pack_start(self.help_bnt)
+ self.help_bnt.connect("clicked", self.on_help_button_clicked)
+ self.buttonbox.set_child_secondary(self.help_bnt, True)
+
self.cancel_bnt = gtk.Button(stock=gtk.STOCK_CANCEL)
self.buttonbox.pack_start(self.cancel_bnt)
self.cancel_bnt.connect("clicked", self.on_cancel_button_clicked)
@@ -599,6 +751,9 @@
def on_cancel_button_clicked(self, obj):
self.users.destroy()
+ def on_help_button_clicked(self, obj):
+ print "on_help_button_clicked"
+
def on_back_button_clicked(self, obj):
if self.notebook.get_current_page() == 1:
self.notebook.set_current_page(0)
@@ -616,7 +771,6 @@
def on_apply_bnt_clicked(self, obj):
data = self.get_new_data()
password = self.xml.get_object("password_entry_1").get_text()
- self.users.destroy()
user = User(nick=data['nick'],
full_name=data['full_name'],
@@ -638,6 +792,20 @@
self.users_manager.insert(user)
+ #Avatar
+ try:
+ avatar_pixbuf = self.user_avatar_image.get_pixbuf()
+ except ValueError:
+ avatar_pixbuf = None
+
+ if self.user_avatar and avatar_pixbuf:
+ path = get_user_avatar_path(user.id)
+
+ try:
+ avatar_pixbuf.save(path, "jpeg", {"quality":"100"})
+ except Exception, error:
+ print error
+
if value:
#Insert Entry in Cash Flow
lctime = localtime()
@@ -652,8 +820,10 @@
citem.day = lctime[2]
citem.hour = current_hour
- self.cash_flow_manager.insert(citem)
+ self.cash_flow_manager.insert(citem)
+ self.users.destroy()
+
def on_show_password_toggle_toggled(self, obj):
status = obj.get_active()
self.xml.get_object("password_entry_1").set_visibility(status)
Modified: trunk/openlh-server/src/OpenlhServer/ui/main.py
===================================================================
--- trunk/openlh-server/src/OpenlhServer/ui/main.py 2008-10-15 20:07:49 UTC (rev 307)
+++ trunk/openlh-server/src/OpenlhServer/ui/main.py 2008-10-16 20:03:22 UTC (rev 308)
@@ -23,6 +23,7 @@
import datetime
from time import localtime
+from os import remove as os_remove
from OpenlhServer.ui.plugins import PluginsWindow
@@ -30,6 +31,7 @@
from OpenlhServer.ui import DateEdit, tray, icons, dialogs, treeview, prefs
from OpenlhServer.ui.SearchEntry import SearchEntry
from OpenlhServer.utils import md5_cripto, get_gtk_builder
+from OpenlhServer.utils import user_has_avatar, get_user_avatar_path
from OpenlhServer.db.models import CashFlowItem, User
from OpenlhServer.globals import *
_ = gettext.gettext
@@ -578,6 +580,13 @@
Parent=self.mainwindow)
if d.response:
+ #Remove Avatar File
+ if user_has_avatar(user.id):
+ try:
+ os_remove(get_user_avatar_path(user.id))
+ except Exception , e:
+ print str(e)
+
self.users_manager.delete(user)
def block_machine_clicked(self, obj):
Modified: trunk/openlh-server/src/OpenlhServer/utils.py
===================================================================
--- trunk/openlh-server/src/OpenlhServer/utils.py 2008-10-15 20:07:49 UTC (rev 307)
+++ trunk/openlh-server/src/OpenlhServer/utils.py 2008-10-16 20:03:22 UTC (rev 308)
@@ -381,4 +381,13 @@
assert os.path.exists(filename)
b = Builder()
b.add_from_file(filename)
- return b
\ No newline at end of file
+ return b
+
+def get_user_avatar_path(user_id):
+ """
+ Get the avatar path for the user
+ """
+ return os.path.join(AVATARS_PATH, "%d.jpeg" % user_id)
+
+def user_has_avatar(user_id):
+ return os.path.exists(get_user_avatar_path(user_id))
\ No newline at end of file
Modified: trunk/openlh-server/src/openlh-server
===================================================================
--- trunk/openlh-server/src/openlh-server 2008-10-15 20:07:49 UTC (rev 307)
+++ trunk/openlh-server/src/openlh-server 2008-10-16 20:03:22 UTC (rev 308)
@@ -114,6 +114,11 @@
sys.exit(3)
CONFIG_PATH_EXISTS = os.path.exists(CONFIG_PATH)
+
+#Check Avatars Path
+if not os.path.exists(AVATARS_PATH):
+ mkdir(AVATARS_PATH)
+
pid_dir = os.path.dirname(SERVER_PID_FILE)
if not os.path.exists(pid_dir):
mkdir(pid_dir)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|