Ejemplo n.º 1
0
def commercialoperator_url(request):
    web_url = request.META['HTTP_HOST']
    template_group = 'commercialoperator'
    TERMS = "/know/online-commercialoperator-booking-terms-and-conditions"

    is_officer = False
    is_admin = False
    is_customer = False

    if request.user.is_authenticated:
         #is_officer = helpers.is_officer(request)
         is_admin = helpers.is_commercialoperator_admin(request)
         is_customer = helpers.is_customer(request)

    return {
        'EXPLORE_PARKS_SEARCH': '/external/payment',
        'EXPLORE_PARKS_CONTACT': '/contact-us',
        #'EXPLORE_PARKS_CONSERVE': '/know/conserving-our-moorings',
        #'EXPLORE_PARKS_PEAK_PERIODS': '/know/when-visit',
        'EXPLORE_PARKS_ENTRY_FEES': '/know/entry-fees',
        'EXPLORE_PARKS_TERMS': TERMS,
        'DEV_STATIC': settings.DEV_STATIC,
        'DEV_STATIC_URL': settings.DEV_STATIC_URL,
        'TEMPLATE_GROUP' : template_group,
        'SYSTEM_NAME' : settings.SYSTEM_NAME,
        'IS_OFFICER' : is_officer,
        'IS_ADMIN' : is_admin,
        'IS_CUSTOMER' : is_customer,
        'PUBLIC_URL' : settings.PUBLIC_URL,
        }
 def validate(self, data):
     request = self.context['request']
     #user = request.user._wrapped if hasattr(request.user,'_wrapped') else request.user
     new_abn=data['abn']
     obj_id=self.instance.id
     if new_abn and obj_id and new_abn!=self.instance.abn:
         if not is_commercialoperator_admin(request):
             raise serializers.ValidationError('You are not authorised to change the ABN')
         else:
             existance = ledger_organisation.objects.filter(abn=new_abn).exclude(id=obj_id).exists()
             if existance:
                 raise serializers.ValidationError('An organisation with the same abn already exists')
     return data
 def get_is_commercialoperator_admin(self, obj):
     request = self.context['request'] if self.context else None
     if request:
         return is_commercialoperator_admin(request)
     return False
Ejemplo n.º 4
0
def is_commercialoperator_admin(context):
    # checks if user is an AdminUser
    request = context['request']
    return commercialoperator_helpers.is_commercialoperator_admin(request)