Example #1
0
def organization(request, organization):
    #Get all source objects
    sources = Source.objects.filter(organization=organization)
    context = navigationlinks(request)
    context['organization'] = organization
    context['source_list'] = sources
    return render(request, 'source/organization.html', context)
Example #2
0
def category(request, category):
    #Get all source objects
    sources = Source.objects.filter(category=category)
    context = navigationlinks(request)
    context['category'] = Source_Category.objects.filter(id=category)
    context['source_list'] = sources
    return render(request, 'source/category.html', context)
Example #3
0
def index(request):
    #Get all source objects
    sources = Source.objects.all()
    context = navigationlinks(request)
    #Assign context
    context['source_list'] = sources
    context['source_category'] = Source_Category.objects.all()
    context['source_organization'] = Source.objects.values(
        'organization').distinct()
    return render(request, 'source/index.html', context)
Example #4
0
def detail(request, collection_id):
    context = navigationlinks(request)
    collection_object = Collection.objects.filter(id=collection_id)
    context['collection'] = collection_object
    context['collection_variable'] = Collection_Variable.objects.filter(
        collection=collection_object)
    context['collection_source'] = Collection_Source.objects.filter(
        collection=collection_object).filter(is_active=True)
    collsource_count = 0
    for source in context['collection_source']:
        collsource_count = collsource_count + 1
    context['collsource_count'] = collsource_count
    return render(request, 'collection/detail.html', context)
Example #5
0
def customdata(request, collection_id):
    context = navigationlinks(request)
    collection_object = Collection.objects.filter(id=collection_id)
    context['collection'] = collection_object
    #Form Procesing
    if request.method == "POST":
        form = CustomCollectionDataForm(request.POST)
        if form.is_valid():
            post = form.save(commit=False)
            post.collection_id = collection_id
            post.date_created = timezone.now()
            post.is_active = True
            post.save()
            redirecturl = '/collection/' + str(collection_id) + '/'
            return redirect(redirecturl)
    else:
        form_class = CustomCollectionDataForm
        context['form'] = form_class
        return render(request, 'collection/customdata.html', context)
    return render(request, 'collection/customdata.html', context)
Example #6
0
def collectsource(request, collection_id):
    context = navigationlinks(request)
    user_object = request.user
    collection_object = Collection.objects.filter(id=collection_id)
    context['collection'] = collection_object
    context['collection_source'] = Collection_Source.objects.filter(
        collection=collection_object).filter(is_active=True)
    active_user_source = Source_User.objects.filter(
        user=user_object.id).filter(is_active=True).values_list('source_id',
                                                                flat=True)
    active_collection_source = Collection_Source.objects.filter(
        collection=collection_object).filter(is_active=True).values_list(
            'source', flat=True)
    unassigned_source = []
    #Determine if a source is part of the collection
    for source in active_user_source:
        if source not in active_collection_source:
            unassigned_source.append(source)
    unassigned_source = Source.objects.filter(id__in=unassigned_source)
    context['unassigned_source'] = unassigned_source
    return render(request, 'collection/collectsource.html', context)
Example #7
0
def add(request):
    context = navigationlinks(request)
    user_object = request.user
    #Form processing
    if request.method == "POST":
        form = CollectionForm(request.POST)
        if form.is_valid():
            post = form.save(commit=False)
            post.date_created = timezone.now()
            post.is_active = True
            post.is_public = False
            post.created_by = user_object
            post.save()
            redirecturl = '/collection/' + str(post.id) + '/'
            collection_object = Collection.objects.get(pk=post.id)
            post_uc = User_Collection(collection=collection_object,
                                      user=user_object)
            post_uc.save()
            return redirect(redirecturl)
    else:
        form_class = CollectionForm
        context['form'] = form_class
        return render(request, 'collection/add.html', context)
    return render(request, 'collection/add.html', context)
Example #8
0
def index(request):
    context = navigationlinks(request)
    return render(request, 'collection/index.html', context)
Example #9
0
def index(request):
	context = navigationlinks(request)
	return render(request, 'welcome/index.html', context)