コード例 #1
0
    def get(self, request, aquifer_id, **kwargs):
        """
        Retrieves version history for the specified Aquifer record and creates a list of diffs
        for each revision.
        """

        try:
            aquifer = Aquifer.objects.get(aquifer_id=aquifer_id)
        except Aquifer.DoesNotExist:
            raise Http404("Aquifer not found")

        # query records in history for this model.
        aquifer_history = [
            obj for obj in aquifer.history.all().order_by(
                '-revision__date_created')
        ]

        aquifer_history_diff = generate_history_diff(aquifer_history,
                                                     'aquifer ' + aquifer_id)

        history_diff = sorted(aquifer_history_diff,
                              key=lambda x: x['date'],
                              reverse=True)

        return Response(history_diff)
コード例 #2
0
ファイル: views.py プロジェクト: anissa-agahchen/gwells
    def get(self, request, well_id):
        """
        Retrieves version history for the specified Well record and creates a list of diffs
        for each revision.
        """

        try:
            well = Well.objects.get(well_tag_number=well_id)
        except Well.DoesNotExist:
            raise Http404("Well not found")

        # query records in history for this model.
        well_history = [
            obj
            for obj in well.history.all().order_by('-revision__date_created')
        ]

        well_history_diff = generate_history_diff(well_history,
                                                  'well ' + well_id)

        history_diff = sorted(well_history_diff,
                              key=lambda x: x['date'],
                              reverse=True)

        return Response(history_diff)
コード例 #3
0
    def get(self, request, person_guid, **kwargs):
        """
        Retrieves version history for the specified Person record and creates a list of diffs
        for each revision.
        """

        try:
            person = Person.objects.get(person_guid=person_guid)
        except Person.DoesNotExist:
            raise Http404("Person not found")

        # query records in history for this model.
        person_history = [
            obj
            for obj in person.history.all().order_by('-revision__date_created')
        ]

        person_history_diff = generate_history_diff(person_history,
                                                    'Person profile')

        registration_history = []
        registration_history_diff = []

        application_history = []
        application_history_diff = []

        # generate diffs for version history in each of the individual's registrations
        for reg in person.registrations.all():
            registration_history = [obj for obj in reg.history.all()]
            registration_history_diff += generate_history_diff(
                registration_history,
                reg.registries_activity.description + ' registration')

            for app in reg.applications.all():
                application_history = [obj for obj in app.history.all()]
                application_history_diff += generate_history_diff(
                    application_history,
                    app.subactivity.description + ' application')

        # generate application diffs

        history_diff = sorted(person_history_diff + registration_history_diff +
                              application_history_diff,
                              key=lambda x: x['date'],
                              reverse=True)

        return Response(history_diff)
コード例 #4
0
ファイル: views.py プロジェクト: ashleydhillon/gwells
    def get(self, request, org_guid):
        try:
            organization = Organization.objects.get(org_guid=org_guid)
        except Organization.DoesNotExist:
            raise Http404("Organization not found")

        # query records in history for this model.
        organization_history = [obj for obj in organization.history.all().order_by(
            '-revision__date_created')]

        history_diff = generate_history_diff(organization_history)

        return Response(history_diff)