Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Merge branch 'achievements' into testing
  • Loading branch information
dtraviglia committed Nov 5, 2015
2 parents 18293f0 + 6a7e8e4 commit 6a793f43d1a9f5937385cc96b61cc5a19de649fd
Showing 13 changed files with 540 additions and 257 deletions.
@@ -4,31 +4,37 @@
# Create your views here.

def home_page(request):
return render(request, 'developerhome.html')
if request.user.is_staff:
return render(request, 'developerhome.html')

def view_dev_status(request):
userprofiles = UserProfile.objects.all()
products = Product.objects.all()
datasets = Dataset.objects.all()
optasks = OpTask.objects.all()
return render(request, 'status.html', {'userprofiles': userprofiles, 'products': products, 'datasets': datasets,'optasks': optasks})
if request.user.is_staff:
userprofiles = UserProfile.objects.all()
products = Product.objects.all()
datasets = Dataset.objects.all()
optasks = OpTask.objects.all()
return render(request, 'status.html', {'userprofiles': userprofiles, 'products': products, 'datasets': datasets,'optasks': optasks})

def view_dev_products(request):
products = Product.objects.all()
return render(request, 'dev_products.html', {'products': products})
if request.user.is_staff:
products = Product.objects.all()
return render(request, 'dev_products.html', {'products': products})

def submit_product(request):
return render(request, 'submit_product.html')
if request.user.is_staff:
return render(request, 'submit_product.html')

def newProduct(request):
dataset = Dataset.objects.create(name=request.POST['product_dataset'])
Product.objects.create(dataset=dataset,
url=request.POST['product_url'],
team=request.POST['product_team'],
name=request.POST['product_name'],
version=request.POST['product_version'],
instructions=request.POST['product_instructions'])
return redirect('/developer/product_comp/')
if request.user.is_staff:
dataset = Dataset.objects.create(name=request.POST['product_dataset'])
Product.objects.create(dataset=dataset,
url=request.POST['product_url'],
team=request.POST['product_team'],
name=request.POST['product_name'],
version=request.POST['product_version'],
instructions=request.POST['product_instructions'])
return redirect('/developer/product_comp/')

def product_comp(request):
return render(request, 'product_comp.html')
if request.user.is_staff:
return render(request, 'product_comp.html')
@@ -2,24 +2,31 @@
from op_tasks.models import UserProfile
from django.core import mail
from django.conf import settings
from tasks import user_authorized

from django.contrib.auth.decorators import login_required


@login_required(login_url='/tasking/login')
def send_email(request):
if request.method == 'POST':
email_to = request.POST.get('email_to', 'xdataonlineerrors@gmail.com')
subject = request.POST.get('email_subject', 'error')
message = request.POST.get('email_message', 'error')
print email_to, subject, message
status = mail.send_mail(subject, message, settings.EMAIL_HOST_USER, [email_to], fail_silently=False)
else:
status = 2
userprofiles = UserProfile.objects.all()
if status == 0:
statusMessage = "The email did not send. Try again."
elif status == 1:
statusMessage = "Email sent!"
elif status == 2:
statusMessage = ""
return render(request, 'email_form.html', {'userprofiles': userprofiles, 'status': status, 'statusMessage': statusMessage})
if user_authorized(request):
if request.method == 'POST':
email_to = request.POST.get('email_to', 'xdataonlineerrors@gmail.com')
subject = request.POST.get('email_subject', 'error')
message = request.POST.get('email_message', 'error')
print email_to, subject, message
status = mail.send_mail(subject, message, settings.EMAIL_HOST_USER, [email_to], fail_silently=False)
else:
status = 2
userprofiles = UserProfile.objects.all()
if status == 0:
statusMessage = "The email did not send. Try again."
elif status == 1:
statusMessage = "Email sent!"
elif status == 2:
statusMessage = ""
return render(request, 'email_form.html', {'userprofiles': userprofiles, 'status': status, 'statusMessage': statusMessage})


def printme(string):
print string
@@ -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')
@@ -2,82 +2,92 @@
from op_tasks.models import UserProfile, Product, Dataset, OpTask, TaskListItem, Experiment
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from xdata.settings import LOGIN_URL

@login_required(login_url='/tasking/login')
def user_authorized(request):
user = request.user
return user.is_staff


@login_required(login_url=LOGIN_URL)
def view_tasks(request):
tasks = OpTask.objects.all()
datasets = Dataset.objects.all()
return render(request, 'tasks.html', {'tasks': tasks, 'datasets':datasets})
if user_authorized(request):
tasks = OpTask.objects.all()
datasets = Dataset.objects.all()
return render(request, 'tasks.html', {'tasks': tasks, 'datasets':datasets})


@login_required(login_url='/tasking/login')
@login_required(login_url=LOGIN_URL)
def view_completed(request):
completed_tasks = TaskListItem.objects.all().filter(task_complete=True).order_by('-date_complete')
return render(request, 'completed.html', {'completed_tasks': completed_tasks})
if user_authorized(request):
completed_tasks = TaskListItem.objects.all().filter(task_complete=True).order_by('-date_complete')
return render(request, 'completed.html', {'completed_tasks': completed_tasks})


@login_required(login_url='/tasking/login')

@login_required(login_url=LOGIN_URL)
def view_incomplete(request):
incomplete_tasks = TaskListItem.objects.all().filter(task_complete=False)
return render(request, 'incomplete.html', {'incomplete_tasks': incomplete_tasks})
if user_authorized(request):
incomplete_tasks = TaskListItem.objects.all().filter(task_complete=False)
return render(request, 'incomplete.html', {'incomplete_tasks': incomplete_tasks})


@login_required(login_url='/tasking/login')
@login_required(login_url=LOGIN_URL)
def add_task(request):
datasets = Dataset.objects.all()
return render(request, 'add_task.html', {'datasets': datasets})
if user_authorized(request):
datasets = Dataset.objects.all()
return render(request, 'add_task.html', {'datasets': datasets})


@login_required(login_url='/tasking/login')
@login_required(login_url=LOGIN_URL)
def new_task(request):
dataset = Dataset.objects.get(name=request.POST['task_dataset'])
task = OpTask()
task.dataset = dataset
task.survey_url = request.POST['task_url']
task.name = request.POST['task_name']
task.instructions = request.POST['task_instructions']
task.exit_url = request.POST['task_exit_url']

task.save()
return redirect('exp_portal:view_tasks')


@login_required(login_url='/tasking/login')
if user_authorized(request):
dataset = Dataset.objects.get(name=request.POST['task_dataset'])
task = OpTask()
task.dataset = dataset
task.survey_url = request.POST['task_url']
task.name = request.POST['task_name']
task.instructions = request.POST['task_instructions']
task.exit_url = request.POST['task_exit_url']
task.save()
return redirect('exp_portal:view_tasks')


@login_required(login_url=LOGIN_URL)
def manage_tasks(request):
return view_tasks(request)
if user_authorized(request):
return view_tasks(request)


@login_required(login_url='/tasking/login')
@login_required(login_url=LOGIN_URL)
def view_task_details(request, taskname):
task = OpTask.objects.all().filter(name=taskname)[0]
datasets = Dataset.objects.all()
print task.dataset.name
for dataset in datasets:
print dataset.name
return render(request, 'task_details.html', {'task': task, 'datasets': datasets})
if user_authorized(request):
task = OpTask.objects.all().filter(name=taskname)[0]
datasets = Dataset.objects.all()
print task.dataset.name
for dataset in datasets:
print dataset.name
return render(request, 'task_details.html', {'task': task, 'datasets': datasets})


@login_required(login_url='/tasking/login')
@login_required(login_url=LOGIN_URL)
def edit_task(request, taskpk):
task = OpTask.objects.get(id=taskpk)
task.name = request.POST['task_name']
task.survey_url = request.POST['task_url']
task.exit_url = request.POST['task_exit_url']
task.instructions =request.POST['task_instructions']

dataset = Dataset.objects.get(name=request.POST['task_dataset'])
task.dataset = dataset

task.is_active = request.POST.get('task_active', False)

task.save()

return redirect('exp_portal:view_tasks')


@login_required(login_url='/tasking/login')
if user_authorized(request):
task = OpTask.objects.get(id=taskpk)
task.name = request.POST['task_name']
task.survey_url = request.POST['task_url']
task.exit_url = request.POST['task_exit_url']
task.instructions =request.POST['task_instructions']
dataset = Dataset.objects.get(name=request.POST['task_dataset'])
task.dataset = dataset
task.is_active = request.POST.get('task_active', False)
task.save()
return redirect('exp_portal:view_tasks')


@login_required(login_url=LOGIN_URL)
def delete_task(request, taskpk):
task = OpTask.objects.get(id=taskpk)
task.delete()

return redirect('exp_portal:view_tasks')
if user_authorized(request):
task = OpTask.objects.get(id=taskpk)
task.delete()
return redirect('exp_portal:view_tasks')
@@ -41,4 +41,8 @@
url(r'^users/tasks/viewall/(?P<profile>.*)$', views.view_user_tasks, name='view_user_tasks'),
url(r'^experiment/products/$', views.view_experiment_products, name='view_experiment_products'),
url(r'^email/$', views.send_email, name='send_email'),
)
)

# print settings.DEBUG, settings.STATIC_ROOT
if settings.DEBUG:
urlpatterns += url(r'^static/(?P<path>.*)$', vs.serve),
@@ -9,6 +9,7 @@ def view_users(request):
userprofiles = UserProfile.objects.all().order_by('-user__last_login')
return render(request, 'users.html', {'userprofiles': userprofiles})


@login_required(login_url='/tasking/login')
def manage_users(request):
userprofiles = UserProfile.objects.all().order_by('-user__last_login')
@@ -156,7 +157,6 @@ def update_user_tasks(request, userpk, datasetpk, productpk, taskpk):

return redirect('exp_portal:add_user_task', userpk)


@login_required(login_url='/tasking/login')
def view_users_experiment(request, experiment_name):
experiment = Experiment.objects.get(name=experiment_name)

0 comments on commit 6a793f4

Please sign in to comment.