This repository has been archived by the owner. It is now read-only.
Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
540 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,75 @@ | ||
from django.shortcuts import render, redirect | ||
from op_tasks.models import Product, Dataset | ||
from django.contrib.auth.decorators import login_required | ||
from tasks import user_authorized | ||
from django.contrib.auth.decorators import login_required | ||
from xdata.settings import LOGIN_URL | ||
|
||
|
||
@login_required(login_url='/tasking/login') | ||
@login_required(login_url=LOGIN_URL) | ||
def view_products(request): | ||
products = Product.objects.all() | ||
return render(request, 'products.html', {'products': products}) | ||
if user_authorized(request): | ||
products = Product.objects.all() | ||
return render(request, 'products.html', {'products': products}) | ||
|
||
|
||
@login_required(login_url='/tasking/login') | ||
@login_required(login_url=LOGIN_URL) | ||
def view_product_details(request, productname): | ||
product = Product.objects.all().filter(name=productname)[0] | ||
datasets = Dataset.objects.all() | ||
return render(request, 'product_details.html', {'product': product, 'datasets': datasets}) | ||
if user_authorized(request): | ||
product = Product.objects.all().filter(name=productname)[0] | ||
datasets = Dataset.objects.all() | ||
return render(request, 'product_details.html', {'product': product, 'datasets': datasets}) | ||
|
||
|
||
|
||
@login_required(login_url='/tasking/login') | ||
@login_required(login_url=LOGIN_URL) | ||
def edit_product(request, productpk): | ||
product = Product.objects.get(id=productpk) | ||
product.name = request.POST['product_name'] | ||
product.team = request.POST['product_team'] | ||
product.url = request.POST['product_url'] | ||
product.instructions = request.POST['instructions_url'] | ||
product.version = request.POST['version'] | ||
product.is_active = request.POST.get('is_active', False) | ||
if user_authorized(request): | ||
product = Product.objects.get(id=productpk) | ||
product.name = request.POST['product_name'] | ||
product.team = request.POST['product_team'] | ||
product.url = request.POST['product_url'] | ||
product.instructions = request.POST['instructions_url'] | ||
product.version = request.POST['version'] | ||
product.is_active = request.POST.get('is_active', False) | ||
|
||
# TODO error checking on this, though it should never fail | ||
dataset = Dataset.objects.all().filter(name=request.POST['dataset'])[0] | ||
product.dataset = dataset | ||
# TODO error checking on this, though it should never fail | ||
dataset = Dataset.objects.all().filter(name=request.POST['dataset'])[0] | ||
product.dataset = dataset | ||
|
||
product.save() | ||
product.save() | ||
|
||
return redirect('exp_portal:view_products') | ||
return redirect('exp_portal:view_products') | ||
|
||
|
||
@login_required(login_url='/tasking/login') | ||
@login_required(login_url=LOGIN_URL) | ||
def manage_products(request): | ||
products = Product.objects.all() | ||
return render(request, 'products.html', {'products': products}) | ||
if user_authorized(request): | ||
products = Product.objects.all() | ||
return render(request, 'products.html', {'products': products}) | ||
|
||
|
||
@login_required(login_url='/tasking/login') | ||
@login_required(login_url=LOGIN_URL) | ||
def add_product(request): | ||
datasets = Dataset.objects.all() | ||
return render(request, 'add_product.html', {'datasets': datasets}) | ||
if user_authorized(request): | ||
datasets = Dataset.objects.all() | ||
return render(request, 'add_product.html', {'datasets': datasets}) | ||
|
||
|
||
@login_required(login_url='/tasking/login') | ||
@login_required(login_url=LOGIN_URL) | ||
def new_product(request): | ||
product = Product(name=request.POST['product_name']) | ||
product.url = request.POST['product_url'] | ||
product.team = request.POST['product_team'] | ||
product.url = request.POST['product_url'] | ||
product.version = request.POST['product_version'] | ||
product.instructions = request.POST['product_instructions'] | ||
product.is_active = request.POST.get('product_active', False) | ||
if user_authorized(request): | ||
product = Product(name=request.POST['product_name']) | ||
product.url = request.POST['product_url'] | ||
product.team = request.POST['product_team'] | ||
product.url = request.POST['product_url'] | ||
product.version = request.POST['product_version'] | ||
product.instructions = request.POST['product_instructions'] | ||
product.is_active = request.POST.get('product_active', False) | ||
|
||
dataset = Dataset.objects.get(name=request.POST['product_dataset']) | ||
product.dataset = dataset | ||
dataset = Dataset.objects.get(name=request.POST['product_dataset']) | ||
product.dataset = dataset | ||
|
||
product.save() | ||
product.save() | ||
|
||
return redirect('exp_portal:view_products') | ||
return redirect('exp_portal:view_products') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.