Beispiel #1
0
 def list(self, request, **kwargs):
     roles = user_service.list_roles(request.user)
     return NSEMonitoringAPIResponse(
         user_service.serialize_roles(request.user,
                                      roles,
                                      many=True,
                                      compact=True))
Beispiel #2
0
 def filter_per_week(self, request, *args, **kwargs):
     ''' View to list stock for a particular company in a given week'''
     stocks = stock_services.filter_stock_per_week(
         requestor=request.user,
         query_params=request.query_params,
         stock_name=kwargs.get('name'),
         week=kwargs.get('week'),
     )
     return NSEMonitoringAPIResponse(
         StockSerializer(stocks, many=True).data)
Beispiel #3
0
 def create(self, request):
     try:
         profile_picture = request.FILES['picture']
     except:
         raise exceptions.NotAcceptable(
             detail='Please select picture to upload')
     profile = user_service.upload_profile_picture(data=request.data,
                                                   requestor=request.user,
                                                   file=profile_picture)
     return NSEMonitoringAPIResponse(FileUploadSerializer(profile).data)
Beispiel #4
0
 def delete(self, request, **kwargs):
     try:
         profile_picture = request.FILES['picture']
     except:
         profile_picture = None
     profile = user_service.delete_profile_picture(
         requestor=request.user,
         file=profile_picture,
         upload_id=kwargs.get('pk'))
     return NSEMonitoringAPIResponse(FileUploadSerializer(profile).data)
Beispiel #5
0
 def update(self, request, **kwargs):
     try:
         profile_picture = request.FILES['picture']
     except:
         raise exceptions.NotAcceptable(
             detail='Please select picture to upload')
     profile = user_service.update_profile_picture(
         requestor=request.user,
         file=profile_picture,
         upload_id=kwargs.get('pk'))
     return NSEMonitoringAPIResponse(FileUploadSerializer(profile).data)
Beispiel #6
0
    def create(self, request, *args, **kwargs):
        ''' Upload stock data'''
        try:
            stock_csv = request.FILES['stock_file']
            if not stock_csv.name.endswith('.csv'):
                raise exceptions.NotAcceptable(
                    detail='Only csv format is allowed')
            elif (stock_csv.multiple_chunks()):
                raise exceptions.NotAcceptable(detail='File size too big')
        except:
            raise exceptions.NotAcceptable(
                detail='Please select stock data to upload')

        stocks = stock_services.load_stock(requestor=request.user,
                                           stock_csv=stock_csv)
        return NSEMonitoringAPIResponse(
            StockSerializer(stocks, many=True).data)
Beispiel #7
0
 def list(self, request):
     ''' List stocks for the the day '''
     stocks = stock_services.list_stocks(requestor=request.user,
                                         query_params=request.query_params)
     return NSEMonitoringAPIResponse(stocks)
Beispiel #8
0
 def retrieve(self, request, **kwargs):
     role = user_service.retrieve_role(request.user,
                                       role_pk=kwargs.get('pk'))
     return NSEMonitoringAPIResponse(
         user_service.serialize_roles(request.user, role))
Beispiel #9
0
 def retrieve(self, request, *args, **kwargs):
     profile = user_service.retrieve_profile(requestor=request.user,
                                             profile_id=kwargs.get('pk'))
     return NSEMonitoringAPIResponse(ViewProfileSerializer(profile).data)
Beispiel #10
0
 def update_user_roles(self, request, **kwargs):
     roles = user_service.update_user_roles(request.user,
                                            profile_pk=kwargs.get('pk'),
                                            data=request.data)
     return NSEMonitoringAPIResponse(
         user_service.serialize_user_roles(request.user, roles))
Beispiel #11
0
 def create(self, request, **kwargs):
     role = user_service.create_role(request.user, data=request.data)
     return NSEMonitoringAPIResponse(
         user_service.serialize_roles(request.user, role))
Beispiel #12
0
 def init(self, request, **kwargs):
     role = user_service.init_role(request.user)
     return NSEMonitoringAPIResponse(
         user_service.serialize_roles(request.user, role))