예제 #1
0
    def post(self, request):
        # data = JSONDeserializer().deserialize(request.body)
        datatype_factory = DataTypeFactory()
        template_id = request.POST.get('template_id')
        parenttile_id = request.POST.get('parenttile_id')
        resourceinstance_id = request.POST.get('resourceinstance_id', None)
        self.resource = Resource.objects.get(
            resourceinstanceid=resourceinstance_id)
        self.resource.load_tiles()

        template_name = self.get_template_path(template_id)
        template_path = os.path.join(settings.APP_ROOT, 'docx', template_name)

        if os.path.exists(
                os.path.join(settings.APP_ROOT, 'uploadedfiles',
                             'docx')) is False:
            os.mkdir(os.path.join(settings.APP_ROOT, 'uploadedfiles', 'docx'))

        self.doc = Document(template_path)
        self.edit_letter(self.resource, datatype_factory)

        date = datetime.today()
        date = date.strftime("%Y") + '-' + date.strftime(
            "%m") + '-' + date.strftime("%d")
        new_file_name = date + '_' + template_name
        new_file_path = os.path.join(settings.APP_ROOT, 'uploadedfiles/docx',
                                     new_file_name)

        new_req = HttpRequest()
        new_req.method = 'POST'
        new_req.user = request.user
        new_req.POST['data'] = None
        host = request.get_host()

        self.doc.save(new_file_path)
        saved_file = open(new_file_path, 'rb')
        stat = os.stat(new_file_path)
        file_data = UploadedFile(saved_file)
        file_list_node_id = "96f8830a-8490-11ea-9aba-f875a44e0e11"  # Digital Object

        tile = json.dumps({
            "tileid": None,
            "data": {
                file_list_node_id: [{
                    "name":
                    new_file_name,
                    "accepted":
                    True,
                    "height":
                    0,
                    "lastModified":
                    stat.st_mtime,
                    "size":
                    stat.st_size,
                    "status":
                    "queued",
                    "type":
                    "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
                    "width":
                    0,
                    "url":
                    None,
                    "file_id":
                    None,
                    "index":
                    0,
                    "content":
                    "blob:" + host + "/{0}".format(uuid.uuid4())
                }]
            },
            "nodegroup_id": "7db68c6c-8490-11ea-a543-f875a44e0e11",
            "parenttile_id": None,
            "resourceinstance_id": "",
            "sortorder": 0,
            "tiles": {}
        })

        new_req = HttpRequest()
        new_req.method = 'POST'
        new_req.user = request.user
        new_req.POST['data'] = tile
        new_req.FILES['file-list_' + file_list_node_id] = file_data
        new_tile = TileData()
        new_tile.action = "update_tile"

        response = TileData.post(new_tile, new_req)
        if response.status_code == 200:
            tile = json.loads(response.content)
            return JSONResponse({'tile': tile, 'status': 'success'})

        return HttpResponseNotFound(response.status_code)
예제 #2
0
 url(r'^resource/related/(?P<resourceid>%s|())$' % uuid_regex, RelatedResourcesView.as_view(), name="related_resources"),
 url(r'^resource/related/candidates', RelatedResourcesView.as_view(action="get_candidates"), name="related_resource_candidates"),
 url(r'^resource/related/relatable', RelatedResourcesView.as_view(action="get_relatable_resources"), name="relatable_resources"),
 url(r'^resource/descriptors/(?P<resourceid>%s|())$' % uuid_regex, ResourceDescriptors.as_view(), name="resource_descriptors"),
 url(r'^resource/(?P<resourceid>%s)/tiles$' % uuid_regex, ResourceTiles.as_view(), name='resource_tiles'),
 url(r'^report/(?P<resourceid>%s)$' % uuid_regex, ResourceReportView.as_view(), name='resource_report'),
 url(r'^report/(?P<resourceid>%s)$' % uuid_regex, ResourceReportView.as_view(), name='resource_report'),
 url(r'^card/(?P<cardid>%s|())$' % uuid_regex, CardView.as_view(action='update_card'), name='card'),
 url(r'^reorder_cards/', CardView.as_view(action='reorder_cards'), name='reorder_cards'),
 url(r'^node/(?P<graphid>%s)$' % uuid_regex, GraphDataView.as_view(action='update_node'), name='node'),
 url(r'^node_layer/(?P<graphid>%s)$' % uuid_regex, GraphDataView.as_view(action='update_node_layer'), name='node_layer'),
 url(r'^widgets/(?P<template>[a-zA-Z_-]*)', main.widget, name="widgets"),
 url(r'^report-templates/(?P<template>[a-zA-Z_-]*)', main.report_templates, name="report-templates"),
 url(r'^function-templates/(?P<template>[a-zA-Z_-]*)', main.function_templates, name="function-templates"),
 url(r'^help-templates$', main.help_templates, name="help_templates"),
 url(r'^tile$', TileData.as_view(action='update_tile'), name="tile"),
 url(r'^tiles/reorder_tiles$', TileData.as_view(action='reorder_tiles'), name='reorder_tiles'),
 url(r'^tiles/tile_history$', TileData.as_view(action='tile_history'), name='tile_history'),
 url(r'^tiles/delete_provisional_tile$', TileData.as_view(action='delete_provisional_tile'), name='delete_provisional_tile'),
 url(r'^templates/(?P<template>[a-zA-Z_\-./]*)', main.templates, name="templates"),
 url(r'^tileserver/*', tileserver.handle_request, name="tileserver"),
 url(r'^map_layer_manager/(?P<maplayerid>%s)$' % uuid_regex, MapLayerManagerView.as_view(), name='map_layer_update'),
 url(r'^map_layer_manager/*', MapLayerManagerView.as_view(), name="map_layer_manager"),
 url(r'^feature_popup_content$', main.feature_popup_content, name="feature_popup_content"),
 url(r'^user$', UserManagerView.as_view(), name="user_profile_manager"),
 url(r'^user/get_user_names$', UserManagerView.as_view(action='get_user_names'), name="get_user_names"),
 url(r'^collector_manager/*', MobileSurveyManagerView.as_view(), name="collector_manager"),
 url(r'^collector_designer/(?P<surveyid>%s)$' % uuid_regex, MobileSurveyDesignerView.as_view(), name='collector_designer'),
 url(r'^mobile_survey_resources/(?P<surveyid>%s)/resources$' % uuid_regex, MobileSurveyResources.as_view(), name='mobile_survey_resources'),
 url(r'^couchdb/(?P<path>.*)$', api.CouchdbProxy.as_view()),
 url(r'^mobileprojects/(?:(?P<surveyid>%s))?$' % uuid_regex, api.Surveys.as_view(), name='mobileprojects'),
예제 #3
0
파일: urls.py 프로젝트: fargeo/arches
    url(r'^resource/descriptors/(?P<resourceid>%s|())$' % uuid_regex, ResourceDescriptors.as_view(), name="resource_descriptors"),
    url(r'^resource/(?P<resourceid>%s)/tiles$' % uuid_regex, ResourceTiles.as_view(), name='resource_tiles'),
    url(r'^report/(?P<resourceid>%s)$' % uuid_regex, ResourceReportView.as_view(), name='resource_report'),
    url(r'^report/(?P<resourceid>%s)$' % uuid_regex, ResourceReportView.as_view(), name='resource_report'),
    url(r'^card/(?P<cardid>%s|())$' % uuid_regex, CardView.as_view(), name='card'),
    url(r'^form/(?P<formid>%s|())$' % uuid_regex, FormView.as_view(), name='form'),
    url(r'^form/(?P<formid>%s)/delete$' % uuid_regex, FormView.as_view(), name='delete_form'),
    url(r'^report_editor/(?P<reportid>%s|())$' % uuid_regex, ReportEditorView.as_view(), name='report_editor'),
    url(r'^report/data$', ResourceReportData.as_view(), name='report_data'),
    url(r'^node/(?P<graphid>%s)$' % uuid_regex, GraphDataView.as_view(action='update_node'), name='node'),
    url(r'^node_layer/(?P<graphid>%s)$' % uuid_regex, GraphDataView.as_view(action='update_node_layer'), name='node_layer'),
    url(r'^widgets/(?P<template>[a-zA-Z_-]*)', main.widget, name="widgets"),
    url(r'^report-templates/(?P<template>[a-zA-Z_-]*)', main.report_templates, name="report-templates"),
    url(r'^function-templates/(?P<template>[a-zA-Z_-]*)', main.function_templates, name="function-templates"),
    url(r'^help-templates$', main.help_templates, name="help_templates"),
    url(r'^tile$', TileData.as_view(action='update_tile'), name="tile"),
    url(r'^tiles/reorder_tiles$', TileData.as_view(action='reorder_tiles'), name='reorder_tiles'),
    url(r'^tiles/delete_provisional_tile$', TileData.as_view(action='delete_provisional_tile'), name='delete_provisional_tile'),
    url(r'^templates/(?P<template>[a-zA-Z_\-./]*)', main.templates, name="templates"),
    url(r'^tileserver/*', tileserver.handle_request, name="tileserver"),
    url(r'^map_layer_manager/(?P<maplayerid>%s)$' % uuid_regex, MapLayerManagerView.as_view(), name='map_layer_update'),
    url(r'^map_layer_manager/*', MapLayerManagerView.as_view(), name="map_layer_manager"),
    url(r'^feature_popup_content$', main.feature_popup_content, name="feature_popup_content"),
    url(r'^user$', UserManagerView.as_view(), name="user_profile_manager"),
    url(r'^user/get_user_names$', UserManagerView.as_view(action='get_user_names'), name="get_user_names"),
    url(r'^mobile_survey_resources/(?P<surveyid>%s)/resources$' % uuid_regex, MobileSurveyResources.as_view(), name='mobile_survey_resources'),
    url(r'^mobile_survey_manager/*', MobileSurveyManagerView.as_view(), name="mobile_survey_manager"),
    url(r'^couchdb/(?P<path>.*)$', api.CouchdbProxy.as_view()),
    url(r'^surveys$', api.Surveys.as_view(), name='surveys'),

    # Uncomment the admin/doc line below to enable admin documentation:
예제 #4
0
 url(r"^resource/related/candidates", RelatedResourcesView.as_view(action="get_candidates"), name="related_resource_candidates"),
 url(r"^resource/related/relatable", RelatedResourcesView.as_view(action="get_relatable_resources"), name="relatable_resources"),
 url(r"^resource/descriptors/(?P<resourceid>%s|())$" % uuid_regex, ResourceDescriptors.as_view(), name="resource_descriptors"),
 url(r"^resource/(?P<resourceid>%s)/tiles$" % uuid_regex, ResourceTiles.as_view(), name="resource_tiles"),
 url(r"^report/(?P<resourceid>%s)$" % uuid_regex, ResourceReportView.as_view(), name="resource_report"),
 url(r"^transaction/(?P<transactionid>%s)/reverse$" % uuid_regex, ReverseTransaction.as_view(), name="transaction_reverse"),
 url(r"^card/(?P<cardid>%s|())$" % uuid_regex, CardView.as_view(action="update_card"), name="card"),
 url(r"^reorder_cards/", CardView.as_view(action="reorder_cards"), name="reorder_cards"),
 url(r"^node/(?P<graphid>%s)$" % uuid_regex, GraphDataView.as_view(action="update_node"), name="node"),
 url(r"^nodegroup/", NodegroupView.as_view(action="exportable"), name="nodegroup"),
 url(r"^node_layer/(?P<graphid>%s)$" % uuid_regex, GraphDataView.as_view(action="update_node_layer"), name="node_layer"),
 url(r"^widgets/(?P<template>[a-zA-Z_-]*)", main.widget, name="widgets"),
 url(r"^report-templates/(?P<template>[a-zA-Z_-]*)", main.report_templates, name="report-templates"),
 url(r"^function-templates/(?P<template>[a-zA-Z_-]*)", main.function_templates, name="function-templates"),
 url(r"^help-templates$", main.help_templates, name="help_templates"),
 url(r"^tile$", TileData.as_view(action="update_tile"), name="tile"),
 url(r"^tiles/reorder_tiles$", TileData.as_view(action="reorder_tiles"), name="reorder_tiles"),
 url(r"^tiles/tile_history$", TileData.as_view(action="tile_history"), name="tile_history"),
 url(r"^tiles/delete_provisional_tile$", TileData.as_view(action="delete_provisional_tile"), name="delete_provisional_tile"),
 url(r"^tiles/download_files$", TileData.as_view(action="download_files"), name="download_files"),
 url(r"^templates/(?P<template>[a-zA-Z_\-./]*)", main.templates, name="templates"),
 url(r"^map_layer_manager/(?P<maplayerid>%s)$" % uuid_regex, MapLayerManagerView.as_view(), name="map_layer_update"),
 url(r"^map_layer_manager/*", MapLayerManagerView.as_view(), name="map_layer_manager"),
 url(r"^feature_popup_content$", main.feature_popup_content, name="feature_popup_content"),
 url(r"^user$", UserManagerView.as_view(), name="user_profile_manager"),
 url(r"^user/get_user_names$", UserManagerView.as_view(action="get_user_names"), name="get_user_names"),
 url(r"^notifications$", NotificationView.as_view(), name="get_notifications"),
 url(r"^notifications/dismiss$", NotificationView.as_view(action="dismiss"), name="dismiss_notifications"),
 url(r"^notifications/get_types$", NotificationView.as_view(action="get_types"), name="get_notification_types"),
 url(r"^notifications/update_types$", NotificationView.as_view(action="update_types"), name="update_notification_types"),
 url(r"^collector_manager/*", MobileSurveyManagerView.as_view(), name="collector_manager"),
예제 #5
0
파일: urls.py 프로젝트: rit/arches
     ReportEditorView.as_view(),
     name='delete_report'),
 url(r'^node/(?P<graphid>%s)$' % uuid_regex,
     GraphDataView.as_view(action='update_node'),
     name='node'),
 url(r'^node_layer/(?P<graphid>%s)$' % uuid_regex,
     GraphDataView.as_view(action='update_node_layer'),
     name='node_layer'),
 url(r'^widgets/(?P<template>[a-zA-Z_-]*)', main.widget, name="widgets"),
 url(r'^report-templates/(?P<template>[a-zA-Z_-]*)',
     main.report_templates,
     name="report-templates"),
 url(r'^function-templates/(?P<template>[a-zA-Z_-]*)',
     main.function_templates,
     name="function-templates"),
 url(r'^tile$', TileData.as_view(action='update_tile'), name="tile"),
 url(r'^tiles/reorder_tiles$',
     TileData.as_view(action='reorder_tiles'),
     name='reorder_tiles'),
 url(r'^templates/(?P<template>[a-zA-Z_\-./]*)',
     main.templates,
     name="templates"),
 url(r'^tileserver/*', tileserver.handle_request, name="tileserver"),
 url(r'^map_layer_manager/(?P<maplayerid>%s)$' % uuid_regex,
     MapLayerManagerView.as_view(),
     name='map_layer_update'),
 url(r'^map_layer_manager/*',
     MapLayerManagerView.as_view(),
     name="map_layer_manager"),
 url(r'^user$', UserManagerView.as_view(), name="user_profile_manager"),
 url(r'^mobile_survey_resources/(?P<surveyid>%s)/resources$' % uuid_regex,
예제 #6
0
    def post(self, request):
        # data = JSONDeserializer().deserialize(request.body)
        datatype_factory = DataTypeFactory()
        template_id = request.POST.get('template_id')
        parenttile_id = request.POST.get('parenttile_id')
        resourceinstance_id = request.POST.get('resourceinstance_id', None)
        self.resource = Resource.objects.get(
            resourceinstanceid=resourceinstance_id)
        self.resource.load_tiles()

        template_name = self.get_template_path(template_id)
        template_path = os.path.join(settings.APP_ROOT, 'docx', template_name)

        if os.path.exists(
                os.path.join(settings.APP_ROOT, 'uploadedfiles',
                             'docx')) is False:
            os.mkdir(os.path.join(settings.APP_ROOT, 'uploadedfiles', 'docx'))

        self.doc = Document(template_path)

        if template_name == 'GLAAS Planning Letter A - No Progression - template.docx':
            self.edit_letter_A(self.resource, datatype_factory)
        elif template_name == 'GLAAS Planning Letter B2 - Predetermination - template.docx':
            self.edit_letter_B2(self.resource, datatype_factory)

        date = datetime.today()
        date = date.strftime("%Y") + '-' + date.strftime(
            "%m") + '-' + date.strftime("%d")
        new_file_name = date + '_' + template_name
        new_file_path = os.path.join(settings.APP_ROOT, 'uploadedfiles/docx',
                                     new_file_name)

        new_req = HttpRequest()
        new_req.method = 'POST'
        new_req.user = request.user
        new_req.POST['data'] = None
        host = request.get_host()

        self.doc.save(new_file_path)
        saved_file = open(new_file_path, 'rt')
        stat = os.stat(new_file_path)
        file_data = UploadedFile(saved_file)
        file_list_node_id = "8d41e4d1-a250-11e9-9a12-00224800b26d"

        tile = json.dumps({
            "tileid": None,
            "data": {
                file_list_node_id: [{
                    "name":
                    new_file_name,
                    "accepted":
                    True,
                    "height":
                    0,
                    "lastModified":
                    stat.st_mtime,
                    "size":
                    stat.st_size,
                    "status":
                    "queued",
                    "type":
                    "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
                    "width":
                    0,
                    "url":
                    None,
                    "file_id":
                    None,
                    "index":
                    0,
                    "content":
                    "blob:" + host + "/{0}".format(uuid.uuid4())
                }]
            },
            "nodegroup_id": "8d41e4d1-a250-11e9-9a12-00224800b26d",
            "parenttile_id": parenttile_id,
            "resourceinstance_id": resourceinstance_id,
            "sortorder": 0,
            "tiles": {}
        })

        new_req = HttpRequest()
        new_req.method = 'POST'
        new_req.user = request.user
        new_req.POST['data'] = tile
        new_req.FILES['file-list_' + file_list_node_id] = file_data
        new_tile_data_instance = TileData()

        post_resp = TileData.post(new_tile_data_instance, new_req)

        if post_resp.status_code == 200:
            return JSONResponse({'tile': tile, 'status': 'success'})

        return HttpResponseNotFound("Error: " + post_resp.status_code)
예제 #7
0
    url(r'^graph/(?P<graphid>%s)/apply_functions$' % uuid_regex, FunctionManagerView.as_view(), name='apply_functions'),
    url(r'^graph/(?P<graphid>%s)/remove_functions$' % uuid_regex, FunctionManagerView.as_view(), name='remove_functions'),
    url(r'^resource$', ResourceListView.as_view(), name='resource'),
    url(r'^resource/(?P<resourceid>%s)$' % uuid_regex, ResourceEditorView.as_view(), name='resource_editor'),
    url(r'^resource/(?P<resourceid>%s)/data/(?P<formid>%s)$' % (uuid_regex, uuid_regex), ResourceData.as_view(), name='resource_data'),
    url(r'^report/(?P<resourceid>%s)$' % uuid_regex, ResourceReportView.as_view(), name='resource_report'),
    url(r'^card/(?P<cardid>%s|())$' % uuid_regex, CardView.as_view(), name='card'),
    url(r'^form/(?P<formid>%s|())$' % uuid_regex, FormView.as_view(), name='form'),
    url(r'^form/(?P<formid>%s)/delete$' % uuid_regex, FormView.as_view(), name='delete_form'),
    url(r'^report_editor/(?P<reportid>%s|())$' % uuid_regex, ReportEditorView.as_view(), name='report_editor'),
    url(r'^report_editor/(?P<reportid>%s)/delete$' % uuid_regex, ReportEditorView.as_view(), name='delete_report'),
    url(r'^node/(?P<graphid>%s)$' % uuid_regex, GraphDataView.as_view(action='update_node'), name='node'),
    url(r'^widgets/(?P<template>[a-zA-Z_-]*)', main.widget, name="widgets"),
    url(r'^report-templates/(?P<template>[a-zA-Z_-]*)', main.report_templates, name="report-templates"),
    url(r'^function-templates/(?P<template>[a-zA-Z_-]*)', main.function_templates, name="function-templates"),
    url(r'^tile$', TileData.as_view(action='update_tile'), name="tile"),
    url(r'^tiles/reorder_tiles$', TileData.as_view(action='reorder_tiles'), name='reorder_tiles'),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', admin.site.urls),
]

urlpatterns += staticfiles_urlpatterns()

if settings.DEBUG:
    from django.conf.urls.static import static
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
예제 #8
0
     name="node"),
 url(r"^nodegroup/",
     NodegroupView.as_view(action="exportable"),
     name="nodegroup"),
 url(r"^node_layer/(?P<graphid>%s)$" % uuid_regex,
     GraphDataView.as_view(action="update_node_layer"),
     name="node_layer"),
 url(r"^widgets/(?P<template>[a-zA-Z_-]*)", main.widget, name="widgets"),
 url(r"^report-templates/(?P<template>[a-zA-Z_-]*)",
     main.report_templates,
     name="report-templates"),
 url(r"^function-templates/(?P<template>[a-zA-Z_-]*)",
     main.function_templates,
     name="function-templates"),
 url(r"^help-templates$", main.help_templates, name="help_templates"),
 url(r"^tile$", TileData.as_view(action="update_tile"), name="tile"),
 url(r"^tiles/reorder_tiles$",
     TileData.as_view(action="reorder_tiles"),
     name="reorder_tiles"),
 url(r"^tiles/tile_history$",
     TileData.as_view(action="tile_history"),
     name="tile_history"),
 url(r"^tiles/delete_provisional_tile$",
     TileData.as_view(action="delete_provisional_tile"),
     name="delete_provisional_tile"),
 url(r"^templates/(?P<template>[a-zA-Z_\-./]*)",
     main.templates,
     name="templates"),
 url(r"^map_layer_manager/(?P<maplayerid>%s)$" % uuid_regex,
     MapLayerManagerView.as_view(),
     name="map_layer_update"),
예제 #9
0
'''
ARCHES - a program developed to inventory and manage immovable cultural heritage.
Copyright (C) 2013 J. Paul Getty Trust and World Monuments Fund
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
from django.conf.urls import include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from arches.app.views import concept, main, map, search, graph, tileserver
from arches.app.views.admin import ReIndexResources
from arches.app.views.graph import GraphManagerView, GraphSettingsView, GraphDataView, DatatypeTemplateView, CardManagerView, CardView, FormManagerView, FormView, ReportManagerView, ReportEditorView, FunctionManagerView, PermissionManagerView, PermissionDataView
from arches.app.views.resource import ResourceEditorView, ResourceListView, ResourceData, ResourceCards, ResourceReportView, RelatedResourcesView, ResourceDescriptors, ResourceEditLogView
from arches.app.views.concept import RDMView
from arches.app.views.user import UserManagerView
from arches.app.views.tile import TileData
from arches.app.views.map import MapLayerManagerView
from arches.app.views.mobile_survey import MobileSurveyManagerView, MobileSurveyResources
from arches.app.views.auth import LoginView, SignupView, ConfirmSignupView, ChangePasswordView, GetTokenView
from arches.app.models.system_settings import settings
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()