예제 #1
0
        if (obj.status == 3):
            delete = ''
            edit = ''
        else:
            delete = '<a class="button delete_vendor_user trash-icon" title="Delete" data-id="%s" href="delete/%s"><i class="fa fa-trash" aria-hidden="true"></i></a>&nbsp;' % (
                obj.id, obj.id)
            edit = '<a class="button edit-icon" title="Edit" data-id="%s" href="/admin/vendor/vendoruser/%s/change/"><i class="fa fa-edit" aria-hidden="true"></i></a>' % (
                obj.id, obj.id)

        view = '<a class="button" title="View" href="view/%s"><i class="fa fa-eye" aria-hidden="true"></i></a>&nbsp;' % (
            obj.id)
        return format_html(view + delete + edit)

    def get_urls(self):
        urls = super().get_urls()
        my_urls = [
            url('^view/(?P<vendor_id>\d+)/$', self.vendor_view),
        ]
        return my_urls + urls

    def vendor_view(self, request, vendor_id):
        context_data = admin_site.each_context(request)
        context_data['data'] = VendorUser.objects.all()
        context_data['site_title'] = ugettext_lazy('Vendor')
        return TemplateResponse(request,
                                'admin/vendor_view.html',
                                context=context_data)


admin_site.register(VendorUser, VendorUserAdmin)
예제 #2
0
    
    def Action(self, obj):
        view = '<a class="button" title="View" href="view/%s"><i class="fa fa-eye" aria-hidden="true"></i></a>&nbsp;' % (
            obj.user_id)
        edit   = '<a class="button edit-icon" title="Edit" data-id="%s" href="/admin/user/user/%s/change/"><i class="fa fa-edit" aria-hidden="true"></i></a>&nbsp;' % (obj.user_id,obj.user_id)

        return format_html(view + edit)

    def save_vendor(self, request, form, formset, change):
        instances = formset.save(commit=False)
        for instance in instances:
            instance.user = request.user
            instance.save()
        formset.save_m2m()

    def extra_context(self, request):
        context = admin_site.each_context(request)
        context['opts'] = Vendor._meta
        context['site_title'] = ugettext_lazy('Vendor')
        return context
    
    @method_decorator(login_required())
    def vendor_view(self, request,vendor_id):
        context = self.extra_context(request)
        context['title']      = 'Vendor Details'
        context['userDetail'] = Vendor.objects.get(user_id=vendor_id)
        context['site_title'] = ugettext_lazy('Vendor')
        return TemplateResponse(request, 'admin/vendor/vendor_view.html', context=context)

admin_site.register(Vendor,VendorAdmin)
예제 #3
0
    def extra_context(self, request):
        context = admin_site.each_context(request)
        context['opts'] = HospitalUser._meta
        context['site_title'] = ugettext_lazy('Hospital')
        return context

    @method_decorator(login_required())
    def vehicle_add(self, request, hospital_id):
        context = self.extra_context(request)
        context['title'] = 'Add Vehicle'
        context['data'] = HospitalUser.objects.get(id=hospital_id)
        context['category'] = VehicleCategory.objects.all()
        return TemplateResponse(request,
                                'admin/hospital/add_vehicle.html',
                                context=context)

    @method_decorator(login_required())
    def hospital_view(self, request, hospital_id):
        context = self.extra_context(request)
        context['title'] = 'Hospital User Details'
        context['userDetail'] = HospitalUser.objects.get(id=hospital_id)
        context['Vehicle'] = Vehicle.objects.filter(
            user_id=hospital_id).filter(user_type=1)
        context['site_title'] = ugettext_lazy('Hospital')
        return TemplateResponse(request,
                                'admin/hospital_view.html',
                                context=context)


admin_site.register(HospitalUser, HospitalUserAdmin)
예제 #4
0

class VehicleCategoryAdmin(admin.ModelAdmin):
    list_display_links = None
    change_list_template = "admin/category/change_list.html"
    form = VehicleCategoryCreationForm
    model = VehicleCategory
    list_display = ('category_name', 'status', 'Action')
    list_filter = ('status', )
    list_per_page = 10

    search_fields = ('category_name', 'status')
    ordering = ('-id', )

    def Action(self, obj):
        if (obj.status == 2):
            delete = ''
            edit = ''
        else:
            edit = '<a class="button edit-icon" title="Edit" data-id="%s" href="/admin/vehicle/vehiclecategory/%s/change/"><i class="fa fa-edit" aria-hidden="true"></i></a>' % (
                obj.id, obj.id)
            delete = '<a class="button delete_category trash-icon" title="Delete" data-id="%s" href="delete/%s"><i class="fa fa-trash" aria-hidden="true"></i></a>&nbsp;' % (
                obj.id, obj.id)

        view = '<a class="button" title="View" href="view/%s"><i class="fa fa-eye" aria-hidden="true"></i></a>&nbsp;' % (
            obj.id)
        return format_html(view + delete + edit)


admin_site.register(Vehicle, VehicleAdmin)
admin_site.register(VehicleCategory, VehicleCategoryAdmin)
예제 #5
0
from django.utils.translation import gettext, gettext_lazy as _
from django.utils.translation import ugettext_lazy
from user.admin import admin_site
from vehicle.models import Vehicle


class VehicleAdmin(admin.ModelAdmin):
    form = CustomVehicleCreationForm
    model = Vehicle
    list_display = ('vehicle_no', 'chassis_no', 'status')
    list_filter = ('status', )
    list_per_page = 5

    fieldsets = ((None, {'fields': ('vehicle_no', 'chassis_no', 'status')}), )
    add_fieldsets = ((None, {
        'classes': ('wide', ),
        'fields': ('vehicle_no', 'chassis_no', 'status')
    }), )
    search_fields = ('company_name', )
    ordering = ('-id', )

    def save_vehicle(self, request, form, formset, change):
        instances = formset.save(commit=False)
        for instance in instances:
            instance.user = request.user
            instance.save()
        formset.save_m2m()


admin_site.register(Vehicle, VehicleAdmin)
예제 #6
0
        edit = '<a class="button edit-icon" title="Edit" data-id="%s" href="/admin/user/user/%s/change/"><i class="fa fa-edit" aria-hidden="true"></i></a>&nbsp;' % (
            obj.user_id, obj.user_id)

        return format_html(view + edit)

    def save_hospital(self, request, form, formset, change):
        instances = formset.save(commit=False)
        for instance in instances:
            instance.user = request.user
            instance.save()
        formset.save_m2m()

    def extra_context(self, request):
        context = admin_site.each_context(request)
        context['opts'] = Hospital._meta
        context['site_title'] = ugettext_lazy('Hospital')
        return context

    @method_decorator(login_required())
    def hospital_view(self, request, hospital_id):
        context = self.extra_context(request)
        context['title'] = 'Hospital Details'
        context['userDetail'] = Hospital.objects.get(user_id=hospital_id)
        context['site_title'] = ugettext_lazy('Hospital')
        return TemplateResponse(request,
                                'admin/hospital/hospital_view.html',
                                context=context)


admin_site.register(Hospital, HospitalAdmin)
        context = self.extra_context(request)
        context['title'] = 'Vendor Details'
        context['userDetail'] = Vendor.objects.get(user_id=vendor_id)
        context['site_title'] = ugettext_lazy('Vendor')
        return TemplateResponse(request,
                                'admin/vendor/vendor_view.html',
                                context=context)


class DriverAdmin(admin.ModelAdmin):
    form = CustomDriverCreationForm

    def has_module_permission(self, request):
        return False

    def response_add(self, request, obj, post_url_continue=None):
        from django.contrib import messages
        messages.add_message(request, messages.SUCCESS,
                             'Driver Added Successfully.')
        return redirect('/admin/vendor/vendor')

    def save_model(self, request, obj, form, change):
        if not change:
            vendorObj = Vendor.objects.get(id=request.GET.get('vid'))
            obj.vendor = vendorObj
            obj.save()


admin_site.register(Driver, DriverAdmin)
admin_site.register(Vendor, VendorAdmin)
    fieldsets = ((None, {'fields': ('category_name', 'status')}), )
    search_fields = (
        'category_name',
        'status',
    )
    ordering = ('-id', )


class FeaturesAdmin(admin.ModelAdmin):
    form = CustomFeaturesCreationForm
    model = Features
    list_display = ('name', 'status')
    list_filter = (
        'name',
        'status',
    )
    list_per_page = 5

    fieldsets = ((None, {'fields': ('name', 'status')}), )
    search_fields = (
        'name',
        'status',
    )
    ordering = ('-id', )


admin_site.register(Features, FeaturesAdmin)
admin_site.register(VehicleCategory, VehicleCategoryAdmin)
admin_site.register(Vehicle, VehicleAdmin)
예제 #9
0
from django.utils.html import format_html
from django.urls import path
from django.conf.urls import include, url
from django.http import HttpResponse
from django.template.response import TemplateResponse
from django.utils.translation import gettext, gettext_lazy as _
from django.utils.translation import ugettext_lazy
from user.admin import admin_site
from booking.models import Booking


class BookingAdmin(admin.ModelAdmin):
    form = CustomBookingCreationForm
    model = Booking
    list_display = ('booking_type', 'origin', 'destination')
    list_filter = ('origin', )
    list_per_page = 5

    fieldsets = ((None, {
        'fields': ('booking_type', 'origin', 'destination')
    }), )
    add_fieldsets = ((None, {
        'classes': ('wide', ),
        'fields': ('booking_type', 'origin', 'destination')
    }), )
    search_fields = ('booking_type', )
    ordering = ('-id', )


admin_site.register(Booking, BookingAdmin)