示例#1
0
 def queryset(self, request):
     qs = super(UserAdmin, self).queryset(request)
     #agent_id_list = AgentProfile.objects.values_list('user_id', flat=True)\
     #    .filter(is_agent=True, manager__isnull=False)
     calendar_user_list = get_all_calendar_user_id_list()
     return qs.filter(is_superuser=False).exclude(
         id__in=calendar_user_list)  # .exclude(id__in=agent_id_list)
示例#2
0
 def queryset(self, request):
     qs = super(UserAdmin, self).queryset(request)
     #agent_id_list = AgentProfile.objects.values_list('user_id', flat=True)\
     #    .filter(is_agent=True, manager__isnull=False)
     calendar_user_list = get_all_calendar_user_id_list()
     qs = qs.filter(is_superuser=False).exclude(id__in=calendar_user_list)  # .exclude(id__in=agent_id_list)
     return qs
示例#3
0
def manager_list():
    """Return all managers of the system"""
    manager_list = []
    agent_id_list = agent_user_id_list()
    calendar_user_id_list = get_all_calendar_user_id_list()
    list = Manager.objects.values_list('id', 'username').filter(is_staff=False, is_superuser=False)\
        .exclude(id__in=agent_id_list).exclude(id__in=calendar_user_id_list).order_by('id')
    for l in list:
        manager_list.append((l[0], l[1]))
    return manager_list
    def list(self, request, *args, **kwargs):
        """get list of all CalendarUser objects"""
        if self.request.user.is_superuser:
            calendar_user_list = get_all_calendar_user_id_list()
        else:
            calendar_user_list = get_calendar_user_id_list(request.user)

        snippets = CalendarUser.objects.filter(
            id__in=calendar_user_list).order_by('id')
        list_data = []

        for c_user in snippets:
            try:
                calendar_obj = Calendar.objects.get(user=c_user)
                calendar_dict = {
                    'name': calendar_obj.name,
                    'max_concurrent': calendar_obj.max_concurrent,
                }
            except:
                calendar_dict = {}

            user_url = 'http://%s/rest-api/calendar-user/%s/' % (
                self.request.META['HTTP_HOST'], str(c_user.id))
            data = {
                'url': user_url,
                'id': c_user.id,
                'username': c_user.username,
                'password': c_user.password,
                'last_name': c_user.last_name,
                'first_name': c_user.first_name,
                'email': c_user.email,
                #'groups': c_user.groups,
                'calendar': calendar_dict,
            }
            list_data.append(data)

        if list_data:
            temp_data = ", ".join(str(e) for e in list_data)
            final_data = ast.literal_eval(temp_data)
        else:
            final_data = {"note": "no calendar-user found"}
        #serializer = CalendarUserSerializer(snippets, many=True)
        return Response(final_data)
    def list(self, request, *args, **kwargs):
        """get list of all CalendarUser objects"""
        if self.request.user.is_superuser:
            calendar_user_list = get_all_calendar_user_id_list()
        else:
            calendar_user_list = get_calendar_user_id_list(request.user)

        profiles = CalendarUserProfile.objects.filter(
            user_id__in=calendar_user_list).order_by('id')
        list_data = []
        for c_user_profile in profiles:
            user_url = 'http://%s/rest-api/calendar-user-profile/%s/' % (
                self.request.META['HTTP_HOST'], str(c_user_profile.id))
            calendar_setting_url = 'http://%s/rest-api/calendar-setting/%s/' % (
                self.request.META['HTTP_HOST'],
                str(c_user_profile.calendar_setting_id))

            data = {
                'url': user_url,
                'id': c_user_profile.id,
                'accountcode': c_user_profile.accountcode,
                'calendar_setting': calendar_setting_url,
                'manager': str(c_user_profile.manager),
                'address': c_user_profile.address,
                'city': c_user_profile.city,
                'state': c_user_profile.state,
                'zip_code': c_user_profile.zip_code,
                'phone_no': c_user_profile.phone_no,
                'fax': c_user_profile.fax,
                'company_name': c_user_profile.company_name,
                'company_website': c_user_profile.company_website,
                #'language': c_user_profile.language,
            }
            list_data.append(data)

        if list_data:
            temp_data = ", ".join(str(e) for e in list_data)
            final_data = ast.literal_eval(temp_data)
        else:
            final_data = {"note": "no calendar-user-profile found"}
        #serializer = CalendarUserSerializer(snippets, many=True)
        return Response(final_data)
    def list(self, request, *args, **kwargs):
        """get list of all CalendarUser objects"""
        if self.request.user.is_superuser:
            calendar_user_list = get_all_calendar_user_id_list()
        else:
            calendar_user_list = get_calendar_user_id_list(request.user)

        snippets = CalendarUser.objects.filter(id__in=calendar_user_list).order_by('id')
        list_data = []

        for c_user in snippets:
            try:
                calendar_obj = Calendar.objects.get(user=c_user)
                calendar_dict = {
                    'name': calendar_obj.name,
                    'max_concurrent': calendar_obj.max_concurrent,
                }
            except:
                calendar_dict = {}

            user_url = 'http://%s/rest-api/calendar-user/%s/' % (self.request.META['HTTP_HOST'], str(c_user.id))
            data = {
                'url': user_url,
                'id': c_user.id,
                'username': c_user.username,
                'password': c_user.password,
                'last_name': c_user.last_name,
                'first_name': c_user.first_name,
                'email': c_user.email,
                #'groups': c_user.groups,
                'calendar': calendar_dict,
            }
            list_data.append(data)

        if list_data:
            temp_data = ", ".join(str(e) for e in list_data)
            final_data = ast.literal_eval(temp_data)
        else:
            final_data = {"note": "no calendar-user found"}
        #serializer = CalendarUserSerializer(snippets, many=True)
        return Response(final_data)
    def list(self, request, *args, **kwargs):
        """get list of all CalendarUser objects"""
        if self.request.user.is_superuser:
            calendar_user_list = get_all_calendar_user_id_list()
        else:
            calendar_user_list = get_calendar_user_id_list(request.user)

        profiles = CalendarUserProfile.objects.filter(user_id__in=calendar_user_list).order_by('id')
        list_data = []
        for c_user_profile in profiles:
            user_url = 'http://%s/rest-api/calendar-user-profile/%s/' % \
                (self.request.META['HTTP_HOST'], str(c_user_profile.id))
            calendar_setting_url = 'http://%s/rest-api/calendar-setting/%s/' % \
                (self.request.META['HTTP_HOST'], str(c_user_profile.calendar_setting_id))

            data = {
                'url': user_url,
                'id': c_user_profile.id,
                'accountcode': c_user_profile.accountcode,
                'calendar_setting': calendar_setting_url,
                'manager': str(c_user_profile.manager),
                'address': c_user_profile.address,
                'city': c_user_profile.city,
                'state': c_user_profile.state,
                'zip_code': c_user_profile.zip_code,
                'phone_no': c_user_profile.phone_no,
                'fax': c_user_profile.fax,
                'company_name': c_user_profile.company_name,
                'company_website': c_user_profile.company_website,
                #'language': c_user_profile.language,
            }
            list_data.append(data)

        if list_data:
            temp_data = ", ".join(str(e) for e in list_data)
            final_data = ast.literal_eval(temp_data)
        else:
            final_data = {"note": "no calendar-user-profile found"}
        #serializer = CalendarUserSerializer(snippets, many=True)
        return Response(final_data)
示例#8
0
    def __init__(self, *args, **kwargs):
        super(EventAdminForm, self).__init__(*args, **kwargs)

        calendar_user_list = get_all_calendar_user_id_list()
        self.fields['creator'].choices = get_calendar_user_list(calendar_user_list)
示例#9
0
    def __init__(self, *args, **kwargs):
        super(EventAdminForm, self).__init__(*args, **kwargs)

        calendar_user_list = get_all_calendar_user_id_list()
        self.fields['creator'].choices = get_calendar_user_list(
            calendar_user_list)