Example #1
0
def add_rmc_site(request):
    """
    This adds an rmc site to
    the database
    """
    context_dict = {}

    if request.method == 'POST':
        form = SiteRMCForm(request.POST)

        if form.is_valid():
            form = form.save()
            return HttpResponseRedirect(reverse('add_rmc_account', args=[form.id]))

    else:
        form = SiteRMCForm()

    context_dict['form'] = form
    return render(request, 'seshdash/add_rmc_site.html', context_dict)
Example #2
0
def edit_site(request,site_Id=1):
    context_dict = {}
    site = get_object_or_404(Sesh_Site, id=site_Id)
    rmc_account = Sesh_RMC_Account.objects.filter(site=site).first();

    # If it is an rmc site create a rmc_form
    if rmc_account:
        site_form = SiteRMCForm(instance=site)
        rmc_form = RMCForm(instance=rmc_account)
        context_dict['RMCForm'] = rmc_form
    else:
        site_form = SiteVRMForm(instance=site)


    if request.method == 'POST':
        if rmc_account:
            site_form = SiteRMCForm(request.POST, instance=site)
            rmc_form = RMCForm(request.POST, instance=rmc_account)

            if site_form.is_valid() and rmc_form.is_valid():
                site_form.save()
                rmc_form.save()
            context_dict['RMCForm'] = rmc_form
        else:
            site_form = SiteVRMForm(request.POST, instance=site)
            if site_form.is_valid():
                site_form.save()


    user_sites = _get_user_sites(request)
    context_dict['VRM_form'] = VRMForm()
    context_dict['site_form']= site_form
    context_dict['sites']= user_sites
    context_dict['permitted'] = get_org_edit_permissions(request.user)
    context_dict['sites_stats'] = get_quick_status(user_sites)
    return render(request,'seshdash/settings/site_settings.html', context_dict)