dpservis / bots

Automatically exported from code.google.com/p/bots
0 stars 0 forks source link

Add: option to add custom entries in menu #141

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
entries can be added in in bots.ini, in section custommenus

Original issue reported on code.google.com by hjebb...@gmail.com on 22 May 2012 at 1:05

GoogleCodeExporter commented 8 years ago
Hi henk-jan,
I have made a few fixes and improvements to this.
1. if no 'custommenus' section exists in bots.ini you get an error (fix with 
try/except). I also found that touchscreen needs a try/except or it gives an 
error first time when there are no user groups.
2. if the menu is saved in a dict; the sequence of menu options cannot be 
controlled (fix by making it a list)
3. case of the key is not preserved when reading from bots.ini ("Outgoing" 
becomes "outgoing"; improve by using .title() method)
4. Improve: can set the menu name eg. menuname = Mike's Menu (default is 
"Custom")
5. Improve: can add menu dividers eg. divider1 = --- (key can be "anything", 
inserts a <hr/>)

Kind Regards,
Mike

Original comment by mjg1964 on 23 May 2012 at 4:34

Attachments:

GoogleCodeExporter commented 8 years ago
hi Mike,

added this.

I can not replicate the problem with the touchscreen.
currently it is implemented like this:
     groups = request.user.groups.values_list('name',flat=True)
     if groups and 'touchscreen' in groups:
         bots_touchscreen = True
     else:
         bots_touchscreen = False
  I think this avoids the problem.

Original comment by hjebb...@gmail.com on 24 May 2012 at 10:47

GoogleCodeExporter commented 8 years ago
I did some debugging on this with your version.
When logged out of bots, request.user = 'AnonymousUser' and 
request.user.groups.values_list('name',flat=True) gives the following error:

Request Method: GET
Request URL: http://localhost:8080/login/

Django Version: 1.3.1
Python Version: 2.7.0
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.admin',
 'bots']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'bots.persistfilters.FilterPersistMiddleware')

Traceback:
File "C:\python27\lib\site-packages\django\core\handlers\base.py" in 
get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "C:\python27\lib\site-packages\django\utils\decorators.py" in _wrapped_view
  93.                     response = view_func(request, *args, **kwargs)
File "C:\python27\lib\site-packages\django\views\decorators\cache.py" in 
_wrapped_view_func
  79.         response = view_func(request, *args, **kwargs)
File "C:\python27\lib\site-packages\django\contrib\auth\views.py" in login
  69.                               context_instance=RequestContext(request, current_app=current_app))
File "C:\python27\lib\site-packages\django\template\context.py" in __init__
  173.             self.update(processor(request))
File "C:\python27\lib\site-packages\bots\bots_context.py" in set_context
  16.     groups = request.user.groups.values_list('name',flat=True)
File "C:\python27\lib\site-packages\django\db\models\manager.py" in values_list
  174.         return self.get_query_set().values_list(*args, **kwargs)
File "C:\python27\lib\site-packages\django\db\models\query.py" in values_list
  514.                 _fields=fields)
File "C:\python27\lib\site-packages\django\db\models\query.py" in _clone
  1033.         c = super(EmptyQuerySet, self)._clone(klass, setup=setup, **kwargs)
File "C:\python27\lib\site-packages\django\db\models\query.py" in _clone
  761.             c._setup_query()
File "C:\python27\lib\site-packages\django\db\models\query.py" in _setup_query
  884.         self.query.add_fields(self.field_names, True)
File "C:\python27\lib\site-packages\django\db\models\sql\query.py" in add_fields
  1574.         alias = self.get_initial_alias()
File "C:\python27\lib\site-packages\django\db\models\sql\query.py" in 
get_initial_alias
  809.             alias = self.join((None, self.model._meta.db_table, None, None))

Exception Type: AttributeError at /login/
Exception Value: 'NoneType' object has no attribute '_meta'

Original comment by mjg1964 on 25 May 2012 at 1:53

GoogleCodeExporter commented 8 years ago
yes, got this error myself now.
(this is always so strange to me. I work a lot with bots, do not get any 
errors; but after the bug is reported I run into it myself ;-))
fixed it (try...except), will put this in repository soon.

Original comment by hjebb...@gmail.com on 25 May 2012 at 11:15

GoogleCodeExporter commented 8 years ago

Original comment by hjebb...@gmail.com on 10 Sep 2013 at 12:45