Example #1
0
	def event_perms(self, user=False):
		permissions = {
	        'can_remove_event':False,
	        'can_edit_event':False,
	        'can_join_event':True,
	        'is_attending_event':False,
	        'can_message_event':False,
	        }
		if not user:
			user=threadlocals.get_current_user()
		if user:
		    operms = self.event_org.org_perms()
		    permissions['is_attending_event'] = self.is_attending(user)
		    if user.is_superuser == 1:
		    	if operms['is_memberof_org']:
			        permissions['can_remove_event'] = True
			        permissions['can_edit_event'] = True
			        permissions['can_message_event'] = True
			        permissions['can_join_event'] = True
		    if self.event_org.get_admin_users().filter(id=user.id):
		    	if operms['is_memberof_org']:
			        permissions['can_remove_event'] = True
			        permissions['can_edit_event'] = True
			        permissions['can_message_event'] = True
			        permissions['can_join_event'] = True		    	
		    else: 
		    	if operms['is_memberof_org']:
			        permissions['can_remove_event'] = self.is_event_coordinator(user) or self.is_creator(user)
			        permissions['can_edit_event'] = self.is_event_coordinator(user) or self.is_creator(user)
			        permissions['can_message_event'] = permissions['is_attending_event']
			
		return permissions
Example #2
0
    def att_perms(self, user=None):
        permissions = {
            'can_remove_attendee': False,
            'can_remove_attendee_after_event': False,
        }
        if not user:
            user = threadlocals.get_current_user()
        if user:
            event = self.att_event

            if user.is_superuser == 1:
                permissions['can_remove_attendee'] = True
                permissions['can_remove_attendee_after_event'] = True
            elif event.event_org.get_admin_users().filter(id=user.id):
                permissions['can_remove_attendee'] = True
                permissions['can_remove_attendee_after_event'] = True
            elif event.is_creator(user) or event.is_event_coordinator(user):
                permissions['can_remove_attendee'] = True
                permissions['can_remove_attendee_after_event'] = True
            else:
                permissions['can_remove_attendee'] = self.is_attending(user)
        return permissions
Example #3
0
	def att_perms(self, user=None):
		permissions = {
	        'can_remove_attendee':False,  
	        'can_remove_attendee_after_event':False,         
	        }
		if not user:
			user=threadlocals.get_current_user()
		if user:
			event = self.att_event

			if user.is_superuser == 1:
				permissions['can_remove_attendee'] = True
				permissions['can_remove_attendee_after_event'] = True
			elif event.event_org.get_admin_users().filter(id=user.id):
				permissions['can_remove_attendee'] = True
				permissions['can_remove_attendee_after_event'] = True
			elif event.is_creator(user) or event.is_event_coordinator(user):
				permissions['can_remove_attendee'] = True
				permissions['can_remove_attendee_after_event'] = True
			else:
				permissions['can_remove_attendee'] = self.is_attending(user)
		return permissions
Example #4
0
    def event_perms(self, user=False):
        permissions = {
            'can_remove_event': False,
            'can_edit_event': False,
            'can_join_event': True,
            'is_attending_event': False,
            'can_message_event': False,
        }
        if not user:
            user = threadlocals.get_current_user()
        if user:
            operms = self.event_org.org_perms()
            permissions['is_attending_event'] = self.is_attending(user)
            if user.is_superuser == 1:
                if operms['is_memberof_org']:
                    permissions['can_remove_event'] = True
                    permissions['can_edit_event'] = True
                    permissions['can_message_event'] = True
                    permissions['can_join_event'] = True
            if self.event_org.get_admin_users().filter(id=user.id):
                if operms['is_memberof_org']:
                    permissions['can_remove_event'] = True
                    permissions['can_edit_event'] = True
                    permissions['can_message_event'] = True
                    permissions['can_join_event'] = True
            else:
                if operms['is_memberof_org']:
                    permissions[
                        'can_remove_event'] = self.is_event_coordinator(
                            user) or self.is_creator(user)
                    permissions['can_edit_event'] = self.is_event_coordinator(
                        user) or self.is_creator(user)
                    permissions['can_message_event'] = permissions[
                        'is_attending_event']

        return permissions
Example #5
0
	def org_perms(self,user=None):
		permissions = {
		'can_add_event':False,   # user can create event in current org
		'can_remove_org':False,  # user can remove the current org
		'can_join_org':False,    # user can join the current org
		'can_edit_org':False,    # user can edit the current org
		'is_memberof_org':False, # user is a member of current org
		'can_add_type':False,    # user can add event type to current org
		'can_remove_type':False, # user can remove event type from current org
		'can_edit_type':False,   # user can edit event_type in current_rog
		'can_edit_group':False,  # user can edit the groups in the org
		'can_remove_groupmember':False, # user can remove a member of the group
		'can_add_group':False,   # user can add groups to this org
		'can_remove_group':False, # user can remove groups in this org
		'can_remove_users':False, # user can remove users in theis org
		'can_invite_users':False, # user can invite users to theis org
		}

		if not user:
			user=threadlocals.get_current_user()
		if user:
			permissions['is_memberof_org'] = self.is_member(user)
			if user.is_superuser == 1:
				permissions['can_join_org'] = True
				if permissions['is_memberof_org']:
					permissions['can_add_event'] = True
					permissions['can_remove_org'] = True
					permissions['can_edit_org'] = True
					permissions['can_add_type'] = True
					permissions['can_remove_type'] = True
					permissions['can_edit_type'] = True
					permissions['can_edit_group'] = True
					permissions['can_remove_groupmember'] = True
					permissions['can_add_group'] = True
					permissions['can_remove_group'] = True
					permissions['can_remove_users'] = True
					permissions['can_invite_users'] = True
			elif self.get_admin_users().filter(id=user.id):
				permissions['can_join_org'] = True
				if permissions['is_memberof_org']:
					permissions['can_add_event'] = True
					permissions['can_remove_org'] = True
					permissions['can_edit_org'] = True
					permissions['can_add_type'] = True
					permissions['can_remove_type'] = True
					permissions['can_edit_type'] = True
					permissions['can_edit_group'] = True
					permissions['can_remove_groupmember'] = True
					permissions['can_add_group'] = True
					permissions['can_remove_group'] = True
					permissions['can_remove_users'] = True
					permissions['can_invite_users'] = True			
			elif self.get_coordinator_users():
				permissions['can_join_org'] = True
				if permissions['is_memberof_org']:
					permissions['can_add_event'] = True
			else:
				if self.org_join_privacy == 0:
					permissions['can_join_org'] = True	
				if self.org_join_privacy == 1 or self.org_join_privacy == 2:
					from org.models import OrgInvite
					if  OrgInvite.objects.filter(org=self, user=user, direction=True) > 0:
						permissions['can_join_org'] = True
						
			if permissions['is_memberof_org']:
				if self.get_orginvite_users().filter(id=user.id):
					permissions['can_invite_users'] = True
		#else:
		#	raise AssertionError(threadlocals.get_current_user())
		
		return permissions