Beispiel #1
0
import data_wizard
from apps.Almacen.models import *

data_wizard.register(Ordenes_Servicio)
data_wizard.register(Peticion_Impresiones_Color)
data_wizard.register(Solicitud_Equipo)
data_wizard.register(Prestamo_Eq_Pub)

Beispiel #2
0
import data_wizard
from .models import Challenge, UserProgram, UserSolution

data_wizard.register(Challenge)
Beispiel #3
0
import data_wizard
from .models import Order

data_wizard.register(Order)
Beispiel #4
0
    )
    search_fields = (
        'code',
        'name',
    )  #display search field
    list_per_page = 30  #limit records displayed on admin site to 15
    exclude = (
        'uuid',
        'date_created',
        'date_lastupdated',
        'code',
    )


data_wizard.register(
    StgKnowledgePipeline
)  #register fact data element to allow wizard driven import


@admin.register(StgKnowledgePipeline)
class Knowledge_Pipeline_Admin(ImportExportModelAdmin,
                               ImportExportActionModelAdmin):
    from django.db import models
    formfield_overrides = {
        models.CharField: {
            'widget': TextInput(attrs={'size': '80'})
        },
        models.TextField: {
            'widget': Textarea(attrs={
                'rows': 3,
                'cols': 120
Beispiel #5
0
                cleaned_data.pop(location_field)
                cleaned_data.pop(categoryoption_field)
                cleaned_data.pop(start_year_field)
                cleaned_data.pop(end_year_field)

                if end_period < start_period:
                    raise ValidationError({
                        'start_period':
                        _('Sorry! Ending year cannot be lower than the start year.\
                            Please make corrections')
                    })
        return cleaned_data


data_wizard.register(
    "Fact Data Indicator Serializer", FactDataIndicatorSerializer
)  #register fact_data indicator to allow wizard driven import


@admin.register(FactDataIndicator)
class IndicatorFactAdmin(OverideImportExport, ImportExportActionModelAdmin):
    form = IndicatorProxyForm  #overrides the default django form
    """
    Davy requested that a user does not see other countries data. This function
    does exactly that by filtering location based on logged in user
    For this reason only the country of the loggied in user is displayed
    whereas the superuser has access to all the countries
    Thanks Good for https://docs.djangoproject.com/en/2.2/ref/contrib/admin/
    because is gave the exact logic of achiving this non-functional requirement
    """
    def get_queryset(self, request):
Beispiel #6
0
        NestedFKSerializer().create(fkdata)
        return instance

    class Meta:
        model = Type
        fields = "__all__"


class NumericCharField(serializers.CharField):
    def to_internal_value(self, data):
        if isinstance(data, float):
            data = int(data)
        return str(data)


class AddressSerializer(serializers.ModelSerializer):
    postal_code = NumericCharField()

    class Meta:
        model = Address
        fields = "__all__"


data_wizard.register(SimpleModel)
data_wizard.register('Simple Model - Incomplete', IncompleteSerializer)
data_wizard.register(FKModel)
data_wizard.register('FK Model By Name', SlugSerializer)
data_wizard.register('New Type + FK Model', NestedSerializer)
data_wizard.register(Address)
data_wizard.register('Address with Zip Code', AddressSerializer)
Beispiel #7
0
import data_wizard
from .models import Item

data_wizard.register(Item)
Beispiel #8
0
import data_wizard
from .models import FileData

data_wizard.register(FileData)
Beispiel #9
0
                    'code',
                    'units_of_measure',
                    'sort_order',
                )  #afrocode may be null
            }), )
    list_display = ['name', 'code', 'units_of_measure']
    list_display_links = (
        'code',
        'name',
    )
    search_fields = ('name', 'code')  #display search field
    list_per_page = 50  #limit records displayed on admin site to 15


data_wizard.register(
    FactHealthCommodities
)  #register fact_data indicator to allow wizard driven import


@admin.register(FactHealthCommodities)
class FactHealthCommoditiesAdmin(OverideExport):
    from django.db import models
    formfield_overrides = {
        models.CharField: {
            'widget': TextInput(attrs={'size': '80'})
        },
    }

    fieldsets = (
        ('Commodity Description', {
            'fields': ('product', 'unit_price', 'comment', 'public_access')

class NumericCharField(serializers.CharField):
    def to_internal_value(self, data):
        if isinstance(data, float):
            data = int(data)
        return str(data)


class AddressSerializer(serializers.ModelSerializer):
    postal_code = NumericCharField()

    class Meta:
        model = Address
        fields = "__all__"


data_wizard.register(SimpleModel)
data_wizard.register('Simple Model - Incomplete', IncompleteSerializer)
data_wizard.register(FKModel)
data_wizard.register('FK Model - Use existing FKs', FKMapExistingSerializer)
data_wizard.register('FK Model - Use FKs always', FKMapAlwaysSerializer)
data_wizard.register('FK Model By Name', SlugSerializer)
data_wizard.register(
    'FK Model By Name - Use existing',
    SlugMapExistingSerializer,
)
data_wizard.register('New Type + FK Model', NestedSerializer)
data_wizard.register(Address)
data_wizard.register('Address with Zip Code', AddressSerializer)
Beispiel #11
0
        model = FKModel
        fields = "__all__"


class NestedFKSerializer(serializers.ModelSerializer):
    class Meta:
        model = FKModel
        fields = ['notes']


class NestedSerializer(serializers.ModelSerializer):
    fkmodel = NestedFKSerializer()

    def create(self, validated_data):
        fkdata = validated_data.pop('fkmodel')
        instance = super(NestedSerializer, self).create(validated_data)
        fkdata['type'] = instance
        NestedFKSerializer().create(fkdata)
        return instance

    class Meta:
        model = Type
        fields = "__all__"


data_wizard.register(SimpleModel)
data_wizard.register('Simple Model - Incomplete', IncompleteSerializer)
data_wizard.register(FKModel)
data_wizard.register('FK Model By Name', SlugSerializer)
data_wizard.register('New Type + FK Model', NestedSerializer)
Beispiel #12
0
        fields = (
            'dataelement',
            'location',
            'period',
            'datasource',
            'start_year',
            'valuetype',
            'end_year',
            'value',
            'target_value',
            'comment',
        )


data_wizard.register(
    FactDataElement
)  #register fact data element serializer to allow wizard driven import


@admin.register(models.FactDataElement)
class DataElementFactAdmin(OverideImportExport, ImportExportActionModelAdmin):
    form = DataElementProxyForm  #overrides the default django form
    """
    Davy requested that a user does not see other countries data. This function
    does exactly that by filtering location based on logged in user. For this
    reason only the country of the loggied in user is displayed whereas the
    superuser has access to all the counties. Thanks to
    https://docs.djangoproject.com/en/2.2/ref/contrib/admin/ because is gave the
    exact logic of achiving this non-functional requirement
    """
    def get_queryset(self, request):