Exemplo n.º 1
0
 def setup(self, request, *args, **kwargs):
     CreateView.setup(self, request, *args, **kwargs)
     if 'category_pk' in self.kwargs:
         self.category = Category.objects.get(
             pk=self.kwargs.get('category_pk')
             )
         self.fields = copy(ListingCreateView.fields)
         self.fields.remove('category')
Exemplo n.º 2
0
 def post(self, request, **kwargs):
     CreateView.post(self, request, kwargs)
     return JsonResponse({
         "editable_data_url" : reverse("productlist-update", args=[self.object.id, 'quantity']),
         "del_button_data_url" : reverse("productlist-delete", args=[self.object.id]),
         "productName" : self.object.product.name,
         "quantity" : self.object.quantity,
         "price" : self.object.product.price,
         "id": self.object.id
     })
Exemplo n.º 3
0
    def test_mixin_get_queryset(self):
        self.moxx.StubOutWithMock(UserModelManager, 'filter_user_objects')
        UserModelManager.filter_user_objects(self.user).AndReturn('object')
        self.moxx.StubOutWithMock(CreateView, 'get_queryset')
        CreateView.get_queryset().AndReturn('pass')

        self.assertEqual(self.view.queryset, None)
        self.moxx.ReplayAll()
        self.view.get_queryset()
        self.moxx.VerifyAll()
        self.assertEqual(self.view.queryset, 'object')
Exemplo n.º 4
0
    def test_dwmixin_get_success_url(self):
        self.moxx.StubOutWithMock(CreateView, 'get_success_url')
        CreateView.get_success_url().AndReturn('pass')
        self.moxx.StubOutWithMock(messages, 'success')
        messages.success(self.request, 'Developer Class Updated.')

        self.assertEqual(self.view.success_url, None)
        self.moxx.ReplayAll()
        self.view.get_success_url()
        self.moxx.VerifyAll()
        self.assertEqual(self.view.success_url, '/dwclass/1')
Exemplo n.º 5
0
    def get_context_data(self, **kwargs):
        context = CreateView.get_context_data(self, **kwargs)
        context["action"] = reverse("relacion_crear", kwargs={"idproyecto": self.kwargs["idproyecto"]})
        if not self.valido:
            context["nodefault"] = "__panel.html"

        return context
Exemplo n.º 6
0
    def get_context_data(self, **kwargs):
        context = CreateView.get_context_data(self, **kwargs)
        instance = get_object_or_404(self.base_model, pk=self.pk)
        context['object'] = instance

        context['product_form'] = self.get_product_form(instance)
        return context
Exemplo n.º 7
0
 def get_context_data(self, **kwargs):
     context = CreateView.get_context_data(self, **kwargs)
     context['action'] = reverse('rol_permisos')
     if self.templ_base_error:
         context['nodefault'] = self.templ_base_error
         context['errormensaje'] = self.mensaje
     return context
Exemplo n.º 8
0
 def get_form_kwargs(self):
     """
     Provide the assignment from the url to the form.
     """
     kwargs = CreateView.get_form_kwargs(self)
     kwargs['assignment'] = get_object_or_404(Assignment, pk=self.kwargs.get('assignment'))
     return kwargs
Exemplo n.º 9
0
 def get_context_data(self, **kwargs):
     context = CreateView.get_context_data(self, **kwargs)
     context['action'] = reverse('rol_fase_crear',\
                             kwargs={'idrolproyecto':self.kwargs['idrolproyecto'] })
     if self.templ_base_error:
         context['nodefault']= self.templ_base_error
     return context
Exemplo n.º 10
0
 def get_form_kwargs(self):
     """Передаем маркер в формы, чтобы у зарегестрированного пользователя отключить
     возможность редактирования поля имени. """
     kwargs = CreateView.get_form_kwargs(self)
     if self.request.user.is_authenticated:
         kwargs["author"] = "authenticated"
     return kwargs
Exemplo n.º 11
0
 def get_context_data(self, **kwargs):
     context = CreateView.get_context_data(self, **kwargs)
     context['idfase'] = self.kwargs['idfase']
     context['action'] = reverse('item_crear', kwargs={'idfase': self.kwargs['idfase']})
     if self.ocurrio_error :
         context['nodefault'] = '__panel.html'
     return context
Exemplo n.º 12
0
 def get_context_data(self, **kwargs):
     c = CreateView.get_context_data(self, **kwargs)
     c['times'] = self.times_form
     c['images'] = self.images_form
     c['links'] = self.links_form
     c['forms_had_errors'] = getattr(self, "forms_had_errors", False)
     return c
Exemplo n.º 13
0
 def post(self, request, *args, **kwargs):
     self.pk = kwargs.pop('pk')
     self.product_form = self.product_form_class(request.POST)
     self.base_instance = get_object_or_404(self.base_model, pk=self.pk)
     self.get_product_form(self.base_instance, post_context=True)
     self.product_form.is_valid()
     return CreateView.post(self, request, *args, **kwargs)
Exemplo n.º 14
0
    def render_to_response(self, context):

        if self.request.is_ajax():
            return JSONHybridProcessFormViewMixin.render_to_response(self,
                                                                     context)

        return CreateView.render_to_response(self, context)
Exemplo n.º 15
0
    def get_context_data(self, **kwargs):
        context = CreateView.get_context_data(self, **kwargs)

        context['extra_fields'] = self.get_extra_fields()
        context["instance"] = self.instance
        context["available_amount"] = self.get_available_amount()
        return context
Exemplo n.º 16
0
    def render_to_response(self, context):

        if self.request.is_ajax():
            return JSONHybridProcessFormViewMixin.render_to_response(
                self, context)

        return CreateView.render_to_response(self, context)
Exemplo n.º 17
0
    def get_form(self, form_class):
        form = CreateView.get_form(self, form_class)
        #carga el selector con tipos de item que no son supertipo
        opciones = [(item.pk, item.idfase.__str__()[0:10] +' - '+ item.nombre) \
                    for item in ItemTipos.objects.filter(es_supertipo=False)]
        form.fields['itemtipoimport'].choices = opciones

        return form
Exemplo n.º 18
0
 def get_form_kwargs(self):
     kwargs = CreateView.get_form_kwargs(self)
     if END_RESERVATION_DATETIME:
         kwargs['initial']['reserved_end_date'] = END_RESERVATION_DATETIME
     if START_RESERVATION_DATETIME:
         kwargs['initial'][
             'reserved_start_date'] = START_RESERVATION_DATETIME
     return kwargs
Exemplo n.º 19
0
 def get_form(self, form_class):
     form = CreateView.get_form(self, form_class)
     #obtiene el proyecto
     self.rolproyecto = get_object_or_404(RolProyecto, pk=self.kwargs['idrolproyecto'])
     #obtiene solo las fases que tiene el proyecto. en lugar de todas las fases.
     proyecto = get_object_or_404(Proyecto,pk=self.rolproyecto.proyecto_id )
     form.fields['fase'].queryset = Fase.objects.filter(idproyecto=proyecto)
     return form
Exemplo n.º 20
0
 def get_context_data(self, **kwargs):
     """
     Provides the current page's assignment to the template context,
     to allow displaying the assignment's name and help text.
     """
     context = CreateView.get_context_data(self, **kwargs)
     context['assignment'] = get_object_or_404(Assignment, pk=self.kwargs['assignment'])
     return context
Exemplo n.º 21
0
 def get_form(self, form_class):
     product = self.get_context_data()['product']
     if product.status == Product.COURIER:
         form_class = CourierCommentForm
     elif self.request.user.is_staff:
         form_class = StaffCommentForm
     else:
         form_class = CommentForm
     return CreateView.get_form(self, form_class)
Exemplo n.º 22
0
 def get_form(self, form_class=None):
     form = CreateView.get_form(self, form_class=form_class)
     form.fields['users'].widget.attrs['class'] = 'chosen-select'
     form.fields['users'].widget.attrs['data-placeholder'] = \
         'Benutzer auswählen ...'
     form.fields['users'].queryset = User.get_users().exclude(
         pk=self.request.user.pk)
     form.fields['location'].queryset = self.request.user.locations
     return form
Exemplo n.º 23
0
    def form_valid(self, form):
        facturier_resp = CreateView.form_valid(self, form)
        facturier_formset = ProjectInlineFormset(self.request.POST,
                                                 instance=self.object)

        if facturier_formset.is_valid():
            facturier_formset.save()

        return facturier_resp
Exemplo n.º 24
0
 def form_valid(self, form):
     form = self.form_class(self.request.POST)
     if form.is_valid():
         mesa = get_object_or_404(Mesa, pk=self.kwargs['pk'])
         resultado = form.save(commit=False)
         resultado.mesa = mesa
         resultado.save()
         return redirect('elecciones:index_resultado', self.kwargs['pk'])
     return CreateView.form_valid(self, form)
Exemplo n.º 25
0
    def post(self, request, *args, **kwargs):
        if "modelpk" in kwargs:
            model_pk = kwargs.pop("modelpk")
            self.instance = self.base_model.objects.get(pk=model_pk)
        elif "model_instance" in request.POST:
            self.instance = self.base_model.objects.get(
                pk=request.POST.get("model_instance"))

        return CreateView.post(self, request, *args, **kwargs)
Exemplo n.º 26
0
 def get_form(self, form_class):
     product = self.get_context_data()['product']
     if product.status == Product.COURIER:
         form_class = CourierCommentForm
     elif self.request.user.is_staff:
         form_class = StaffCommentForm
     else:
         form_class = CommentForm
     return CreateView.get_form(self, form_class)
Exemplo n.º 27
0
 def get_form(self, form_class=None):
     form = CreateView.get_form(self, form_class=form_class)
     self.user1 = self.request.user
     self.user2 = User.objects.get(
         pk=self.request.resolver_match.kwargs.get('partner_pk')
         )
     form.instance.user1 = self.user1
     form.instance.user2 = self.user2
     return form
Exemplo n.º 28
0
    def get_initial(self):
        initial = CreateView.get_initial(self)
        initial.update({'owner': self.request.user})

        tipo = self.request.GET.get('tipo', '10')

        initial.update({'tipo': tipo})

        return initial
Exemplo n.º 29
0
Arquivo: views.py Projeto: cmjatai/cmj
    def get_initial(self):
        initial = CreateView.get_initial(self)
        initial.update({'owner':
                        self.request.user})

        tipo = self.request.GET.get('tipo', '10')

        initial.update({'tipo': tipo})

        return initial
Exemplo n.º 30
0
Arquivo: views.py Projeto: cmjatai/cmj
    def get_initial(self):
        self.initial = {'parent': self.parent}

        cod__max = Classe.objects.filter(
            parent=self.parent).order_by('codigo').aggregate(Max('codigo'))

        self.initial['codigo'] = cod__max['codigo__max'] + \
            1 if cod__max['codigo__max'] else 1

        return CreateView.get_initial(self)
Exemplo n.º 31
0
    def form_valid(self, form):
        result = CreateView.form_valid(self, form)

        title = form.cleaned_data['title']
        messages.add_message(self.request,
                             messages.SUCCESS,
                             '{} quiz created.'.format(title),
                             extra_tags='safe')

        return result
Exemplo n.º 32
0
    def get_initial(self):
        self.initial = {'parent': self.parent}

        cod__max = Classe.objects.filter(
            parent=self.parent).order_by('codigo').aggregate(Max('codigo'))

        self.initial['codigo'] = cod__max['codigo__max'] + \
            1 if cod__max['codigo__max'] else 1

        return CreateView.get_initial(self)
Exemplo n.º 33
0
 def form_valid(self, form):
     #verifica que solo exista un solo registro del par (usuario, proyecto)
     miembro = ComiteProyecto.objects.filter(proyecto=form.instance.proyecto, \
                                             usuario =form.instance.usuario)
     if miembro.count()>0 :
         messages.error(self.request, 'ya existe este miembro para este proyecto')
         self.ocurrio_error = True
         return self.form_invalid(form)
     
     return CreateView.form_valid(self, form)
Exemplo n.º 34
0
 def get_context_data(self, **kwargs):
     data = CreateView.get_context_data(self, **kwargs)
     product = get_object_or_404(Product, pk=self.kwargs['pk'])
     data['product'] = product
     data['user'] = self.request.user
     if product.courier:
         data['courier'] = Courier.objects.get(pk=product.courier)
     data['comment_list'] = product.comment_set.all().order_by('id')
     data['comment_form'] = CommentForm(initial={'user': self.request.user, 'product': product})
     data['hardware_comment_form'] = CommentForm(initial={'user': self.request.user, 'product': product})
     return data
Exemplo n.º 35
0
 def get_initial(self):
     self.initial = CreateView.get_initial(self)
     if self.request.user.is_authenticated:
         self.initial["author"] = self.request.user.username
     if self.kwargs["key"] == "article":
         self.initial["foreignkey_to_article"] = get_object_or_404(
             Article, pk=self.kwargs["pk"])
     else:
         self.initial["foreignkey_to_boat"] = get_object_or_404(
             BoatModel, pk=self.kwargs["pk"])
     return self.initial.copy()
Exemplo n.º 36
0
 def get_context_data(self, **kwargs):
     context = CreateView.get_context_data(self, **kwargs)
     context['preconditions_formset'] = TestCasePreConditionFormSet(
         self.request.POST or None, instance=self.model())
     context['postconditions_formset'] = TestCasePostConditionFormSet(
         self.request.POST or None, instance=self.model())
     context['steps_formset'] = TestCaseStepFormSet(self.request.POST
                                                    or None,
                                                    instance=self.model())
     context['revision_form'] = TestCaseRevisionForm(self.request.POST
                                                     or None)
     return context
Exemplo n.º 37
0
def register(request):
    if request.method == 'POST':
        form = UserCreationForm(request.POST)
        if form.is_valid():
            form.save()
            new_user = authenticate(username=form.cleaned_data['username'],
                                    password=form.cleaned_data['password1'])
            login(request, new_user)
            return HttpResponseRedirect("/")
    return CreateView.as_view(template_name='registration/register.html',
                              form_class=RegisterForm,
                              success_url='/accounts/login/')(request)
Exemplo n.º 38
0
 def form_valid(self, form):
     #verificamos que aun no este asignado:
     #el usuario  a un  proyecto con algun rol
     qs = RolProyecto.objects.filter(usuario=form.instance.usuario
                                ).filter(proyecto=form.instance.proyecto)
     #si ya esta asignado enviamos un mensaje de error
     if (qs.count() > 0):
         messages.error(self.request, 'Esta asignacion ya existe, solo puede asignar \
         un rol a un usuario para un proyecto.')
         self.templ_base_error = "__panel.html"
         return self.form_invalid(form)
     return CreateView.form_valid(self, form)
Exemplo n.º 39
0
    def form_valid(self, form):
        note = form.save(commit=False)
        note.author = self.request.user

        model = self.request.POST['content_type']
        if model not in ['account', 'contact', 'deal', 'case']:
            raise BaseException("Invalid content_type")

        object_id = self.request.POST['object_id']
        content_type = ContentType.objects.get(model=model)
        note.subject = content_type.get_object_for_this_type(id=object_id)
        note.save()
        return CreateView.form_valid(self, form)
Exemplo n.º 40
0
 def form_valid(self, form):
     #verificamos que aun no este asignado:
     #el usuario  a un  proyecto con algun rol
     
     qs = RolFases.objects.filter(rolproyecto_id=self.kwargs['idrolproyecto']).\
         filter(fase=form.instance.fase)
         
     #si ya esta asignado enviamos un mensaje de error
     if (qs.count() != 0):
         messages.error(self.request, 'Este permiso para la fase ya existe, para este usuario')
         self.templ_base_error = "__panel.html"
         return self.form_invalid(form)
     return CreateView.form_valid(self, form)
Exemplo n.º 41
0
Arquivo: views.py Projeto: cmjatai/cmj
    def get_context_data(self, **kwargs):
        context = CreateView.get_context_data(self, **kwargs)

        tipo = int(self.request.GET.get('tipo', '10'))

        tipos = Solicitacao.TIPO_SOLICITACAO_CHOICE

        context['title'] = _(
            'Registar uma Solicitação: (%s)') % tipos.triple_map[tipo]['text']

        context['bg_title'] = opts_bg[tipo]

        return context
Exemplo n.º 42
0
    def get_context_data(self, **kwargs):
        context = CreateView.get_context_data(self, **kwargs)

        tipo = int(self.request.GET.get('tipo', '10'))

        tipos = Solicitacao.TIPO_SOLICITACAO_CHOICE

        context['title'] = _(
            'Registar uma Solicitação: (%s)') % tipos.triple_map[tipo]['text']

        context['bg_title'] = opts_bg[tipo]

        return context
Exemplo n.º 43
0
    def form_valid(self, form):
        note = form.save(commit=False)
        note.author = self.request.user

        model = self.request.POST['content_type']
        if model not in ['account', 'contact', 'deal', 'case']:
            raise BaseException("Invalid content_type")

        object_id = self.request.POST['object_id']
        content_type = ContentType.objects.get(model=model)
        note.subject = content_type.get_object_for_this_type(id=object_id)
        note.save()
        return CreateView.form_valid(self, form)
Exemplo n.º 44
0
 def get_initial(self):
     self.initial = CreateView.get_initial(self)
     self.initial["author"] = self.request.user
     if self.kwargs["pk"] and self.kwargs["pk"] != 0:
         self.initial["foreignkey_to_subheading"] =\
             get_object_or_404(SubHeading, pk=self.kwargs["pk"])
     try:  # устанавливаем нач. знач поля foreignkey_to_boat если заходим с категории                    #Articles on boats
         current_subheading = get_object_or_404(SubHeading,
                                                pk=self.kwargs["pk"])
         self.initial[
             "foreignkey_to_boat"] = current_subheading.one_to_one_to_boat
     except Http404:
         pass
     return self.initial.copy()
Exemplo n.º 45
0
    def form_valid(self, form):
        ret = CreateView.form_valid(self, form)
        idtipo_import = self.request.POST.get('itemtipoimport')
        #tipo_item = get_object_or_404(ItemTipos, pk=idtipo_import) 
        atributos = ItemAtributos.objects.filter(idtipoitem_id=idtipo_import)
        for atr in atributos:
            nuevoattr = ItemAtributos()
            nuevoattr.idtipoitem = form.instance
            nuevoattr.nombre = atr.nombre
            nuevoattr.descripcion = atr.descripcion
            nuevoattr.tipodato = atr.tipodato
            nuevoattr.save()

        return ret 
Exemplo n.º 46
0
    def form_valid(self, form):
        result = CreateView.form_valid(self, form)

        url = 'https://{}/admin/main/archivalcollectionsuggestion/{}/'.format(
            self.request.get_host(), form.instance.id)
        msg = '''
            An archival collection was suggested. See details here: {}
        '''.format(url)

        # Send an email to the team
        send_mail('Archival Collection Suggested', msg, settings.SERVER_EMAIL,
                  (settings.CONTACT_US_EMAIL, ))

        return result
Exemplo n.º 47
0
 def get_form(self, form_class):
     form = CreateView.get_form(self, form_class)
     # el selector solo debe desplegar los items del proyecto
     fases = Fase.objects.filter(idproyecto_id=self.kwargs["idproyecto"])
     # lista los items que coinciden con las fases de proyecto
     items = Item.objects.filter(idfase__in=fases).exclude(estado=Item.E_ELIMINADO)
     # cargamos los selectores con los items y mostrando a que fase pertenecen
     opciones = [
         (item.pk, "[" + item.idfase.__unicode__()[0:5] + "..] " + "[" + item.estado + "]  | " + item.nombre[0:40])
         for item in items
     ]
     form.fields["origen"].choices = opciones
     form.fields["destino"].choices = opciones
     return form
Exemplo n.º 48
0
    def form_valid(self, form):
        title = form.cleaned_data.get('title')
        instructor = self.request.user

        result = CreateView.form_valid(self, form)

        form.instance.instructors.add(instructor)

        messages.add_message(
            self.request, messages.SUCCESS,
            '<strong>{}</strong> cohort created.'.format(title),
            extra_tags='safe'
        )

        return result
Exemplo n.º 49
0
    def form_valid(self, form):
        # establece el tipo de la relacion , si es interna a la fase o externa
        # es decir padre e hijo o antecesor sucesor.
        form.instance.set_tipo()
        relacion_str = form.instance.__unicode__()
        origen = form.instance.origen
        destino = form.instance.destino
        # Serie de validaciones
        if self.valid_relacion_unica(origen, destino):
            messages.error(self.request, "ERROR : La relacion ya existe: " + relacion_str)
            self.valido = False
            return self.form_invalid(form)
        # valida la existencia de un ciclo
        if self.valid_existe_ciclo(form.instance.origen_id, form.instance.destino_id):
            messages.error(self.request, "ERROR : Se ha detectado un ciclo: " + relacion_str)
            self.valido = False
            return self.form_invalid(form)
        # valida que el antecesor este en linea base y el el hijo no tenga linea base si el hijo si
        if not self.valid_ant_lineabase(origen, destino):
            messages.error(
                self.request,
                "ERROR : Si es una relacion interfase: \
            El item antecesor o padre debe estar en linea.Si es una relacion intra-fase:\
            El item hijo no debe tener linea base. ",
            )
            self.valido = False
            return self.form_invalid(form)
        #
        if not self.valid_intra_fase_bloq(origen, destino):
            messages.error(
                self.request,
                "ERROR : Si es una relacion intrafase y ambos items \
            ya estan en linea base entonces la relacion ya no esta permitida. \
            En estado desarrollo debe establecer las relaciones",
            )
            self.valido = False
            return self.form_invalid(form)

        messages.info(self.request, "Relacion creada : " + relacion_str)
        return CreateView.form_valid(self, form)
Exemplo n.º 50
0
    def form_valid(self, form) -> HttpResponse:
        title = form.cleaned_data['title']

        student_grp_name = '{}-group-{}'.format(title, uuid4())
        fac_grp_name = '{}-faculty-group-{}'.format(title, uuid4())
        student_grp = Group(name=student_grp_name)
        student_grp.save()
        student_grp.user_set.add(self.request.user)

        fac_grp = Group(name=fac_grp_name)
        fac_grp.save()
        fac_grp.user_set.add(self.request.user)

        form.instance.group = student_grp
        form.instance.faculty_group = fac_grp

        result = CreateView.form_valid(self, form)
        messages.add_message(
            self.request, messages.SUCCESS,
            '<strong>{}</strong> sandbox course created.'.format(title)
        )
        return result
Exemplo n.º 51
0
 def form_invalid(self, form):
     self.templ_base_error = "__panel.html"
     return CreateView.form_invalid(self, form)
Exemplo n.º 52
0
 def get_context_data(self, **kwargs):
     context = CreateView.get_context_data(self, **kwargs)
     context['action'] = reverse('rol_proyecto_crear')
     if self.templ_base_error:
         context['nodefault'] = self.templ_base_error
     return context
Exemplo n.º 53
0
 def form_invalid(self, form):
     log.debug("form is not valid")
     log.debug(form.errors)
     return CreateView.form_invalid(self, form)
Exemplo n.º 54
0
from django.conf.urls.defaults import *
from django.views.generic.edit import CreateView, DeleteView
from tinygraph.apps.definitions.models import Package
from tinygraph.apps.definitions.forms import PackageForm

urlpatterns = patterns('definitions.views',
    url(r'^mibs/$', 'mib_upload_list', name='mib_upload_list'),
    
    url(r'^packages/$', 'package_list', name='package_list'),
    url(r'^packages/add/$', CreateView.as_view(
        model=Package,
        template_name='definitions/packages/package_form.html',
        form_class=PackageForm,
    ), name='package_add'),
    url(r'^packages/(?P<package_slug>[-\w]+)/$', 'package_detail', name='package_detail'),
    url(r'^packages/(?P<slug>[-\w]+)/delete$', DeleteView.as_view(
        model=Package,
        template_name='definitions/packages/package_delete.html',
        success_url='/data/packages/',
    ), name='package_delete'),

    url(r'^$', 'data_object_list', name='data_object_list'),
)
Exemplo n.º 55
0
from django.conf.urls.defaults import patterns, include, url
from django.views.generic.base import TemplateView
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import UpdateView, CreateView

from web.barns.models import Barn

urlpatterns = patterns('',
    url(r'^$', ListView.as_view(model=Barn, template_name='generic/list.html'), name='list'),
    url(r'^/(?P<pk>\d+)$', DetailView.as_view(model=Barn, template_name='generic/detail.html'), name='detail'),
    
    url(r'^/new$', CreateView.as_view(model=Barn, template_name='generic/form.html', success_url='/barns/%(id)s'), name='create'),
    url(r'^/(?P<pk>\d+)/edit$', UpdateView.as_view(model=Barn, template_name='generic/form.html', success_url='/barns/%(id)s'), name='edit'),
)
Exemplo n.º 56
0
    # auth
    url(r'', include('social_auth.urls')),

    url(r'^accounts/logout/$',
        'django.contrib.auth.views.logout',
        {'next_page': '/'},
        name='auth_logout'),

    url(r'^accounts/login/$',
        'django.contrib.auth.views.login',
        {'template_name': 'accounts/login.html'},
        name='auth_login'),

    url(r'^accounts/register/$',
        CreateView.as_view(
            template_name='accounts/register.html',
            form_class=UserCreationForm,
            success_url='/',),
        name='auth_register'),

    # students
    url(r'^$',
        'studentapp.views.students.students_list', name='home'),

    url(r'^students/add/$',
        'studentapp.views.students.add_student', name='add_student'),

    url(r'^students/edit/(?P<pk>\d+)/$',
        'studentapp.views.students.edit_student', name='edit_student'),

    url(r'^students/delete/(?P<pk>\d+)/$',
        StudentDeleteView.as_view(), name='delete_student'),
Exemplo n.º 57
0
from wbinventory.forms import ItemForm
from wbinventory.models import Item, ItemTransaction
from wbinventory.views import SiteSearchListView, ItemDetailView, ItemTransactionCreateView


urlpatterns = patterns('wbinventory.views',
    url(
        r'^$',
        'index',
        name='wbinventory_index',
    ),
    url(
        r'^items/create/$',
        CreateView.as_view(
            context_object_name='item',
            template_name='wbinventory/item/create.html',
            model=Item,
            form_class=ItemForm,
        ),
        name='wbinventory_item_create',
    ),
    url(
        r'^items/(?P<pk>\d+)/$',
        ItemDetailView.as_view(
            context_object_name='item',
            template_name='wbinventory/item/detail.html',
            model=Item,
        ),
        name='wbinventory_item_detail',
    ),
    url(
        r'^items/(?P<pk>\d+)/edit/$',
Exemplo n.º 58
0
from django.views.generic.base import TemplateView
from django.views.generic.edit import CreateView, DeleteView, UpdateView
from django.views.generic.list import ListView
from money.forms import CategoryForm, BillForm
from money.models import Bill, Category
from money.views import BillCreateView, StatsView
from django.contrib.auth.decorators import login_required

urlpatterns = patterns('',
    url(r"^category/$", login_required(ListView.as_view(
        model=Category,
        template_name="list_category.html"
    )), name="category"),
    url(r"^category/add/$", login_required(CreateView.as_view(
        model=Category,
        template_name="form_category.html",
        form_class=CategoryForm,
        success_url="/category/",
    )), name="category_add"),
    url(r"^category/rm/(?P<pk>\d+)/$", login_required(DeleteView.as_view(
        queryset=Category.objects.order_by("name"),
        template_name="confirm_category.html",
        success_url="/category/",
    )), name="category_remove"),
    url(r"^category/update/(?P<pk>\d+)/$", login_required(UpdateView.as_view(
        model=Category,
        template_name="form_category.html",
        form_class=CategoryForm,
        success_url="/category/",
    )), name="category_update"),
    url(r"^bill/add/$", login_required(BillCreateView.as_view(
        template_name="form_bill.html",
Exemplo n.º 59
0
 def form_valid(self, form):
     #user = User.objects.create_user('x', 'x.com', self.request.POST.get('password'))
     form.instance.set_password(self.request.POST.get('password'))
     return CreateView.form_valid(self, form)