Exemplo n.º 1
0
# along with objdetec.  If not, see <http://www.gnu.org/licenses/>.

from django.contrib.auth.decorators import login_required
from django.db import transaction
from django.db.models import Q
from django.utils.decorators import method_decorator
from django.views import generic
from nnmodels.models import NNModel
from objdetec.decorators import piwik
from results.models import Result

from ..forms import ImageFormSet, SetForm
from ..models import Set


@method_decorator(piwik('Set • Images • objdetec'), name='dispatch')
class DetailView(generic.DetailView):
    model = Set

    def get_queryset(self):
        if self.request.user.is_staff:
            return Set.objects.all()
        elif self.request.user.is_authenticated:
            return Set.objects.filter(
                Q(public=True) | Q(uploader=self.request.user))
        else:
            return Set.objects.filter(public=True)

    def get_context_data(self, **kwargs):
        context = super(DetailView, self).get_context_data(**kwargs)
Exemplo n.º 2
0
from django.http import HttpResponseForbidden
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext_lazy as _
from django.views import generic
from django.views.decorators.csrf import csrf_protect
from images.models import Image
from nnmodels.models import Version
from objdetec.decorators import piwik

from ..forms import JobForm, JobSetForm
from ..models import Job


@method_decorator(login_required, name='dispatch')
@method_decorator(piwik('Jobs • Results • objdetec'), name='dispatch')
class ListView(generic.ListView):
    context_object_name = 'jobs'
    model = Job
    paginate_by = 100

    def get_queryset(self):
        jobs = Job.objects.all()
        if not self.request.user.is_staff:
            jobs = jobs.filter(user=self.request.user)
        return jobs


@method_decorator(login_required, name='dispatch')
@method_decorator(piwik('Job • Results • objdetec'), name='dispatch')
class DetailView(generic.DetailView):
Exemplo n.º 3
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with objdetec.  If not, see <http://www.gnu.org/licenses/>.

import json

from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
from django.views import generic
from nnmodels.forms import VersionForm
from nnmodels.models import NNModel, Version
from objdetec.decorators import piwik


@method_decorator(piwik('Version • NN Model • N Models • objdetec'),
                  name='dispatch')
class DetailView(generic.DetailView):
    model = Version
    slug_field = 'nnmodel__slug'
    query_pk_and_slug = True

    def get_queryset(self):
        if self.request.user.is_staff:
            return Version.objects.all()
        elif self.request.user.is_authenticated:
            return Version.objects.filter(
                Q(nnmodel__public=True)
                | Q(nnmodel__uploader=self.request.user))
        else:
            return Version.objects.filter(nnmodel__public=True)
Exemplo n.º 4
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with objdetec.  If not, see <http://www.gnu.org/licenses/>.

from django.contrib.auth.decorators import login_required
from django.db.models import Q
from django.utils.decorators import method_decorator
from django.views import generic
from nnmodels.forms import NNModelForm
from nnmodels.models import NNModel
from objdetec.decorators import piwik


@method_decorator(piwik('NN Models • NN Models • objdetec'), name='dispatch')
class ListView(generic.ListView):
    context_object_name = 'nnmodels'
    model = NNModel
    paginate_by = 100

    def get_queryset(self):
        if self.request.user.is_staff:
            return NNModel.objects.all()
        elif self.request.user.is_authenticated:
            return NNModel.objects.filter(
                Q(public=True) | Q(uploader=self.request.user))
        else:
            return NNModel.objects.filter(public=True)

Exemplo n.º 5
0

@csrf_protect
@login_required
@piwik('Profile • objdetec')
def profile(request):
    user = get_object_or_404(User, pk=request.user.pk)
    if request.method == 'POST':
        form = UserChangeForm(instance=request.user, data=request.POST)
        if form.is_valid():
            user = form.save()
            messages.success(request,
                             _('Your profile has been successfully updated.'))
    else:
        form = UserChangeForm(instance=request.user)
    return render(request, 'profiles/profile_detail.html', locals())


@method_decorator(login_required, name='dispatch')
@method_decorator(piwik('Profile • objdetec'), name='dispatch')
class UpdateView(generic.edit.UpdateView):
    model = User
    form_class = UserChangeForm

    def get_object(self, queryset=None):
        return self.request.user

    def get_success_url(self):
        from django.urls import reverse
        return reverse('profiles:profile')
Exemplo n.º 6
0
# -*- coding: utf-8 -*-
# Copyright (C) 2018 Nathanael Philipp (jnphilipp) <*****@*****.**>
#
# This file is part of objdetec.
#
# objdetec is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# objdetec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with objdetec.  If not, see <http://www.gnu.org/licenses/>.

from django.shortcuts import render
from django.utils.decorators import method_decorator
from django.views.generic.base import TemplateView
from objdetec.decorators import piwik


@method_decorator(piwik('Dashboard • objdetec'), name='dispatch')
class DashboardView(TemplateView):
    template_name = 'objdetec/dashboard.html'
Exemplo n.º 7
0
 path('nnmodel/', nnmodel.ListView.as_view(), name='nnmodel_list'),
 path('nnmodel/<int:page>/', nnmodel.ListView.as_view()),
 path('nnmodel/create/',
      nnmodel.CreateView.as_view(),
      name='nnmodel_create'),
 path('nnmodel/<slug:slug>/',
      nnmodel.DetailView.as_view(),
      name='nnmodel_detail'),
 path('nnmodel/<slug:slug>/edit/',
      nnmodel.UpdateView.as_view(),
      name='nnmodel_edit'),
 path('nnmodel/<slug:slug>/create/',
      version.CreateView.as_view(),
      name='version_create'),
 path('nnmodel/<slug:slug>/<int:pk>/',
      piwik('Version • NN Model • N Models • objdetec')(
          version.DetailView.as_view()),
      name='version_detail'),
 path('nnmodel/<slug:slug>/<int:pk>/config/',
      piwik('Config • Version • NN Model • N Models • objdetec')(
          version.DetailView.as_view()),
      name='version_config'),
 path('nnmodel/<slug:slug>/<int:pk>/plot/',
      piwik('Plot • Version • NN Model • N Models • objdetec')(
          version.DetailView.as_view()),
      name='version_plot'),
 path('nnmodel/<slug:slug>/<int:pk>/edit/',
      version.UpdateView.as_view(),
      name='version_edit'),
 path('nnmodel/<slug:slug>/<int:pk>/charts/trainhistory/',
      version.charts.trainhistory,
      name='version_chart_trainhistory'),
Exemplo n.º 8
0
from django.urls import path
from django.views.generic.base import RedirectView
from objdetec.decorators import piwik

from . import views


app_name = 'profiles'
urlpatterns = [
    path('', RedirectView.as_view(pattern_name='profiles:profile'),
         name='index'),
    path('profile/', views.UpdateView.as_view(), name='profile'),

    path('password/',
         piwik('Password change • Profile • objdetec')(
            auth_views.PasswordChangeView.as_view(
                success_url='/profiles/password/done/')),
         name='password_change'),
    path('password/done/',
         piwik('Password change • Profile • objdetec')(
            auth_views.PasswordChangeDoneView.as_view()),
         name='password_change_done'),


    path('password/reset/',
         piwik('Password reset • Profile • objdetec')(
            auth_views.PasswordResetView.as_view(
                success_url='/profiles/password/reset/done/')),
         name='password_reset'),

    path('password/reset/done/',