Changeset - 319b08c756e5
[Not reviewed]
default
0 1 0
Dennis Fink - 9 years ago 2016-03-17 23:54:27
dennis.fink@c3l.lu
Some state adjustments
1 file changed with 8 insertions and 4 deletions:
0 comments (0 inline, 0 general)
spaceapi/utils.py
Show inline comments
 
@@ -50,30 +50,34 @@ class ActiveStatus(Singleton, dict):
 
            last_state = {}
 
            last_state['state'] = self['state']
 
            last_state['sensors'] = self['sensors']
 
            json.dump(last_state, f, sort_keys=True)
 

	
 
    def add_user_present(self, username):
 
        if self['state']['open']:
 
            if 'people_now_present' not in self['sensors']:
 
                self['sensors']['people_now_present'] = {'value': 0}
 

	
 
            people_now_present = self['sensors']['people_now_present']
 

	
 
            people_now_present['value'] += 1
 
            if 'names' in people_now_present and username not in people_now_present['names']:
 
                people_now_present['value'] += 1
 

	
 
            if username in current_app.config['PEOPLE_NOW_PRESENT_ALLOWED']:
 
                if 'names' in people_now_present and username not in people_now_present['names']:
 
                if username in current_app.config['PEOPLE_NOW_PRESENT_ALLOWED']:
 
                    people_now_present['names'].append(username)
 
                else:
 

	
 
            elif 'names' not in people_now_present:
 
                people_now_present['value'] += 1
 

	
 
                if username in current_app.config['PEOPLE_NOW_PRESENT_ALLOWED']:
 
                    people_now_present['names'] = [username]
 

	
 
            self['sensors']['people_now_present'] = people_now_present
 
        else:
 
            pass
 

	
 
    def remove_user_present(self, username):
 
        if self['state']['open'] and 'people_now_present' in self['sensors']:
 
            people_now_present = self['sensors']['people_now_present']
 

	
 
            if people_now_present['value'] > 0:
 
                people_now_present['value'] -= 1
0 comments (0 inline, 0 general)