Example #1
0
def create_update_map(request, pk=None):

    if pk:
        map_obj = Map.objects.get(pk=pk)
    else:
        map_obj = None

    if request.method == 'POST':
        form = MapForm(request.POST, prefix='map', instance=map_obj)
        maplayers_formset = MapInlineFormset(request.POST,
                                             prefix='layers',
                                             instance=map_obj)

        if form.is_valid() and maplayers_formset.is_valid():
            form.save()
            maplayers_formset.save()
            return HttpResponseRedirect(reverse('job-list'))
    else:
        form = MapForm(prefix='map', instance=map_obj)
        maplayers_formset = MapInlineFormset(prefix='layers', instance=map_obj)
    return render_to_response('core/generic_form.html', {
        'form': form,
        'layer_formset': maplayers_formset,
        'custom_form': 'core/map_create.html',
        'object': map_obj,
    },
                              context_instance=RequestContext(request))
Example #2
0
def create_update_map(request, job_id, map_id):
    if map_id:
        map_obj = Map.objects.get(pk=map_id)
    else:
        map_obj = None

    if request.method == 'POST':
        form = MapForm(request.POST, prefix='map', instance=map_obj)
        maplayers_formset = MapInlineFormset(request.POST,
                                             prefix='layers',
                                             instance=map_obj)

        if form.is_valid() and maplayers_formset.is_valid():
            form.save()
            maplayers_formset.instance = form.instance
            maplayers_formset.save()
            return HttpResponseRedirect(
                reverse('job-detail', kwargs={'pk': job_id}))
    else:
        form = MapForm(prefix='map', instance=map_obj)
        maplayers_formset = MapInlineFormset(prefix='layers', instance=map_obj)

    # form = [f for f in form if f.name not in ['zoom', 'projection', 'center_x', 'center_y']]

    return render_to_response('core/generic_form.html', {
        'form': form,
        'layer_formset': maplayers_formset,
        'custom_form': 'core/map_create.html',
        'object': map_obj,
    },
                              context_instance=RequestContext(request))
Example #3
0
File: views.py Project: Bauerr/geoq
def create_update_map(request, pk=None):

    if pk:
        map_obj = Map.objects.get(pk=pk)
    else:
        map_obj = None

    if request.method == 'POST':
        form = MapForm(request.POST, prefix='map', instance=map_obj)
        maplayers_formset = MapInlineFormset(request.POST, prefix='layers', instance=map_obj)

        if form.is_valid() and maplayers_formset.is_valid():
            form.save()
            maplayers_formset.instance = form.instance
            maplayers_formset.save()
            return HttpResponseRedirect(reverse('map-list'))
    else:
        form = MapForm(prefix='map', instance=map_obj)
        maplayers_formset = MapInlineFormset(prefix='layers', instance=map_obj)
    return render_to_response('core/generic_form.html', {
        'form': form,
        'layer_formset': maplayers_formset,
        'custom_form': 'core/map_create.html',
        'object': map_obj,
        }, context_instance=RequestContext(request))
Example #4
0
def addMapView(request, eventid):
	event = EventModel.getEvent(eventid)
	
	user=request.user
	if memberCheck(request.user, event) == False:
			return render(request, 'invite/notMember.html', {'menu' : getMenuInfo(request), 'title' : "Not Member"})
	creator = isCreator(request.user, event)
	coplanner = isCoplanner(request.user, event)
	if creator == False:
		if coplanner == False:
			return render(request, 'events/notPermission.html', \
			{'menu' : getMenuInfo(request), 'title' : 'Not Permission'})

	if request.method == 'GET':
		mapform=MapForm()

		context = {'menu' : getMenuInfo(request), 'title' : "Add Map", \
		  'cur_path' : request.get_full_path(), 'event' : event, 'mapform':mapform,  }
		return render(request, 'maps/addMap.html', context)

	if request.method == 'POST':
		mapform=MapForm(request.POST)
		
		if mapform.is_valid():
			gmap=Gmap(event=event,location=request.POST['location'])
			gmap.save()
			
		return HttpResponseRedirect(reverse('events:tools:maps:maps', kwargs={'eventid':eventid,}))
Example #5
0
def create_update_map(request, job_id, map_id):
    if map_id:
        map_obj = Map.objects.get(pk=map_id)
    else:
        map_obj = None

    if request.method == 'POST':
        form = MapForm(request.POST, prefix='map', instance=map_obj)
        maplayers_formset = MapInlineFormset(request.POST, prefix='layers', instance=map_obj)

        if form.is_valid() and maplayers_formset.is_valid():
            form.save()
            maplayers_formset.instance = form.instance
            maplayers_formset.save()
            return HttpResponseRedirect(reverse('job-detail', kwargs = {'pk': job_id}))
    else:
        form = MapForm(prefix='map', instance=map_obj)
        maplayers_formset = MapInlineFormset(prefix='layers', instance=map_obj)

    # form = [f for f in form if f.name not in ['zoom', 'projection', 'center_x', 'center_y']]

    return render_to_response('core/generic_form.html', {
        'form': form,
        'layer_formset': maplayers_formset,
        'custom_form': 'core/map_create.html',
        'object': map_obj,
        }, context_instance=RequestContext(request))
Example #6
0
def map_create(request):
    form = MapForm(request.POST or None, request.FILES or None)

    if form.is_valid():
        instance = form.save(commit=False)
        instance.save()
        messages.success(request, "Successfully Created")
        return redirect('mlist')

    context = {
        'form': form,
    }
    return render(request, 'aquarium/generic_form.html', context)
Example #7
0
def map_update(request, id=None):
    instance = get_object_or_404(Map, id=id)

    form = MapForm(request.POST or None, request.FILES or None, instance=instance)

    if form.is_valid():
        instance = form.save(commit=False)
        instance.save()
        messages.success(request, "Successfully Updated")
        return redirect('mlist')

    context = {
        'form': form,
    }
    return render(request, 'aquarium/generic_form.html', context)
Example #8
0
File: views.py Project: Carl4/geoq
def create_map(request):

    if request.method == 'POST':
        map = MapForm(request.POST, prefix='map')
        layer_formset = MapInlineFormset(request.POST, prefix='layers')
        if map.is_valid() and layer_formset.is_valid():
            # do something with the cleaned_data on the formsets.
            m = map.save(commit=False)
            layer_formset.instance = m
            m.save()
            layer_formset.save()
            return HttpResponseRedirect(reverse('job-list'))
    else:
        map = MapForm(prefix='map')
        layer_formset = MapInlineFormset(prefix='layers')
        print layer_formset.management_form.as_p
    return render_to_response('core/generic_form.html', {
        'form': map,
        'layer_formset': layer_formset,
        'custom_form': 'core/map_create.html',
        },context_instance=RequestContext(request))