def __init__(self): self.create = login_required( CreateView.as_view( model=self.model, fields=('name', ), success_url=reverse_lazy('laboratory:laboratory_list'), template_name=self.template_name_base + 'form.html')) self.edit = login_required( UpdateView.as_view( model=self.model, fields=('name', ), success_url=reverse_lazy('laboratory:laboratory_list'), template_name=self.template_name_base + 'form.html')) self.delete = login_required( DeleteView.as_view( model=self.model, success_url=reverse_lazy('laboratory:laboratory_list'), template_name=self.template_name_base + 'delete.html')) self.list = login_required( ListView.as_view(model=self.model, paginate_by=10, template_name=self.template_name_base + 'list.html'))
def __init__(self): self.create = login_required(CreateView.as_view( model=self.model, fields=('name',), success_url=reverse_lazy('laboratory:laboratory_list'), template_name=self.template_name_base + 'form.html' )) self.edit = login_required(UpdateView.as_view( model=self.model, fields=('name',), success_url=reverse_lazy('laboratory:laboratory_list'), template_name=self.template_name_base + 'form.html' )) self.delete = login_required(DeleteView.as_view( model=self.model, success_url=reverse_lazy('laboratory:laboratory_list'), template_name=self.template_name_base + 'delete.html' )) self.list = login_required(ListView.as_view( model=self.model, paginate_by=10, template_name=self.template_name_base + 'list.html' ))
def form_valid(self, form): thetime = timezone.now() thetime = thetime.replace(hour=0, minute=0, second=0, microsecond=0) universe = Universe(current_time=thetime, mode='Arcade') universe.save() form.instance.universe = universe form.instance.created_igt = universe.current_time form.instance.mode = "Arcade" slug = slugify(form.instance.name) retry = 1 while Enterprise.objects.filter(slug=slug).count() != 0: slug = slugify(form.instance.name + ' ' + retry) retry += 1 form.instance.slug = slug response = CreateView.form_valid(self, form) form.instance.owners.add(self.request.user) action = ActionRecord(enterprise=form.instance, when_igt=universe.current_time, description='Enterprise %s started' % form.instance.name) action.save() form.instance.add_transaction(details='Initial Investment', acc_type='Equity', amount=form.instance.start_cash) game.start_game(form.instance) return response
def get_form(self, form_class=None): form = CreateView.get_form(self, form_class=form_class) id_proprietaire = self.request.GET.get("proprietaire", "") if id_proprietaire: proprietaire = Proprietaire.objects.get(id=id_proprietaire) form.fields["proprietaire"].initial = proprietaire form.fields["emplacement"].initial = EmplacementChoice.PENSION.name return form
def render_to_response(self, context, **response_kwargs): image_form = ReportImageCreateForm() report_form = ReportCreateForm() context['image_form'] = image_form context['report_form'] = report_form #context["formset"] = self.formset return CreateView.render_to_response(self, context, **response_kwargs)
def get_form(self, form_class=None): form = CreateView.get_form(self, form_class=form_class) self.id_proprietaire = self.request.GET.get("proprietaire", "") proprietaire = Proprietaire.objects.get(id=self.id_proprietaire) form.fields["proprietaire"].initial = proprietaire return form
def form_valid(self, form): """ Sets initial values which are hidden in the form """ form.instance.user = self.request.user form.instance.instrument = get_object_or_404( Instrument, name=self.instrument_obj.name) return CreateView.form_valid(self, form)
def form_valid(self, form): devis_resp = CreateView.form_valid(self, form) devis_formset = DevisInlineFormset(self.request.POST, instance=self.object) if devis_formset.is_valid(): devis_formset.save() return devis_resp
def get_form(self, form_class): form = CreateView.get_form(self, form_class) zona = self.request.user.profile.zona if zona != None: form.fields["hospitales"].queryset = self.request.user.profile.zona.hospitales else: messages.warning(self.request, u"Aún no ha configurado su Zona, se muestran todos los Hospitales") return form
def test_works_with_create_view_get(self): viewfn = CreateView.as_view( form_class=UserProfileMultiForm, template_name='noop.html', ) factory = RequestFactory() request = factory.get('/') # This would fail as CreateView passes instance=None viewfn(request)
def form_valid(self, form): line_resp = CreateView.form_valid(self, form) line_formset = lineInlineFormset(self.request.POST, instance=self.object) if line_formset.is_valid(): line_formset.save() return line_resp
def post(self, request, *args, **kwargs): print(request.POST) print(request.FILES) iform = ReportImageCreateForm(request.POST, request.FILES) print(iform) return CreateView.post(self, request, *args, **kwargs)
def get_form(self, form_class=None): form = CreateView.get_form(self, form_class=form_class) id_proprietaire = self.request.GET.get("proprietaire", "") if id_proprietaire: proprietaire = Proprietaire.objects.get(id=id_proprietaire) form.fields["proprietaire"].initial = proprietaire form.fields["animaux"].queryset = Animal.objects.filter( proprietaire_id=id_proprietaire).filter( inactif=False).order_by("nom") return form
def get_initial(self): initial_data = CreateView.get_initial(self) experiment_id = self.request.GET.get('experiment', None) if experiment_id is not None: initial_data['experiment'] = Experiment.objects.get( id=experiment_id) analysis_id = self.kwargs.get('pk', None) if analysis_id is not None: initial_data['analysis'] = Analysis.objects.get(id=analysis_id) return initial_data
def get_context_data(self, **kwargs): context = CreateView.get_context_data(self, **kwargs) context['analysis'] = Analysis.objects.get_subclass( id=self.kwargs.get('pk', None)) context['experiment'] = Experiment.objects.get( id=self.request.GET.get('experiment', None)) context['conditions'] = Condition.objects.filter( experiment=context['experiment']) context['events'] = Event.objects.filter( trial__condition__experiment__id=self.request.GET.get( 'experiment', None)).values_list('name', flat=True).distinct() return context
def user_register(request, pk=None): view_kwargs = { 'model': User, 'form_class': UserRegisterForm, 'template_name': "people/register_form.html", } if pk is None: view_kwargs['success_url'] = "/people/profile/%(id)d/" return CreateView.as_view(**view_kwargs)(request) else: return UpdateView.as_view(**view_kwargs)(request, pk=pk)
def route(request, view_kwargs={}, pk=None): """ Route to the correct view based on Method or the existance of pk. """ if request.method == "DELETE": return DeleteView.as_view(**view_kwargs)(request=request, pk=pk) else: if pk: return UpdateView.as_view(**view_kwargs)(request=request, pk=pk) else: return CreateView.as_view(**view_kwargs)(request=request)
def post(self, request, **kwargs): data = CreateView.post(self, request, **kwargs) form = self.get_form() inst = form.instance inst.user = request.user inst.save() return data # class ProductDeleteView(DeleteView): # pass # def get_context_data(self,**kwargs): # data = DeleteView.get_context_data(self,**kwargs) # import pdb;pdb.set_trace()
def test_works_with_create_view_post(self): viewfn = CreateView.as_view( form_class=BadgeMultiForm, # required after success success_url='/', template_name='noop.html', ) factory = RequestFactory() request = factory.post('/', data={ 'badge1-name': 'foo', 'badge1-color': 'blue', 'badge2-name': 'bar', 'badge2-color': 'purple', }) resp = viewfn(request) self.assertEqual(resp.status_code, 302) self.assertEqual(Badge.objects.count(), 2)
urlpatterns = patterns('', url(r'^node_list/$', ListView.as_view( queryset=NetworkNode.objects.all(), context_object_name='nodes', template_name='django_dhcp/list.html'), name="node_list"), url(r'^(?P<pk>[0-9]+)/$', DetailView.as_view( model=NetworkNode, template_name='django_dhcp/detail.html', context_object_name='node' ), name="detail"), url(r'^create/$', CreateView.as_view( model=NetworkNode, template_name='django_dhcp/create.html',), name="create"), url(r'^update/(?P<pk>[0-9]+)/$', UpdateView.as_view(model=NetworkNode, template_name='django_dhcp/update.html'), name="update"), ) try: from djangoautoconf import create_tastypie_resource urlpatterns += (r'^api/node/', include(create_tastypie_resource(NetworkNode))) except: pass
from django.conf.urls import patterns, url from qipei.apps.product.models import Sorts, Products #from qipei.apps.store.models import Stores from qipei.apps.account.models import Links #from qipei.apps.store.forms import EditStoreForm, StoreAdForm #from django.contrib.comments import Comment from django.views.generic import UpdateView, CreateView, ListView, DeleteView from django.core.urlresolvers import reverse_lazy urlpatterns = patterns( 'qipei.apps.product', ## products url( r'^create$', CreateView.as_view(model=Products, template_name="create_product.html", success_url=reverse_lazy("list_product")), name="create_product", ), url(r'^create/self$', 'views.create_product', name="create_self_product"), url(r'^list$', 'views.list_product', name="list_product"), # url(r'^update/(?P<pk>\d+)$', # UpdateView.as_view( # model = Products, # template_name="update_product.html", # success_url = reverse_lazy("manage_products") # ), # name="update_product" # ), url( r'^update/(?P<product_id>\d+)$',
from django.conf.urls import patterns, include, url from django.contrib.auth.decorators import login_required from django.contrib import admin admin.autodiscover() from django.views.generic import CreateView, DetailView, ListView from swiss.models import Player, Tournament, Round from swiss.forms import TournamentAddForm from swiss.views import TournamentDetailView, TournamentCreateView, RoundDetailView, set_result, start_next_round_view, final_calcs urlpatterns = patterns('', url(r'player/(?P<pk>\d+)/', DetailView.as_view(model=Player), name="player"), url(r'players/', ListView.as_view(model=Player), name="players"), url(r'new_player/', login_required(CreateView.as_view(model=Player)), name="new_player"), url(r'final_calcs/(?P<pk>\d+)/$', login_required(final_calcs), name="final_calcs"), url(r'start_next_round/(?P<pk>\d+)/$', login_required(start_next_round_view), name="start_next_round"), url(r'tournament/(?P<pk>\d+)/$', TournamentDetailView.as_view(model=Tournament), name="tournament"), url(r'tournaments/', ListView.as_view(model=Tournament), name="tournaments"), url(r'new_tournament/', login_required(TournamentCreateView.as_view(model=Tournament, form_class=TournamentAddForm)), name="new_tournament"), url(r'matchup/(?P<pk>\d+)/(?P<result>\w+)/', login_required(set_result), name="matchup"), url(r'round/(?P<pk>\d+)/', RoundDetailView.as_view(model=Round), name="round"), )
url(r'^$', TemplateView.as_view(template_name="pgmanager/index.html")), url(r'^home/', home_view), url(r'^register/', register_view), url(r'^register/', register_view), url(r'^login/', login_view), url(r'^signout/', signout_view), url( r'^pgs/', ListView.as_view( model=PG, #template_name="pgmanager/", #queryset=PG.objects.all(), # fields= )), url(r'^pg_create/', CreateView.as_view(model=PG, fields="__all__", success_url='/pgs/')), url(r'^pg_update/(?P<pk>[0-9]+)', UpdateView.as_view(model=PG, fields="__all__", success_url='/pgs/')), url(r'^pg_delete/(?P<pk>[0-9]+)', DeleteView.as_view(model=PG, success_url='/pgs/')), url( r'^room_create/', CreateView.as_view(model=Room, fields="__all__", success_url='/rooms/')), url( r'^room_update/(?P<pk>[0-9]+)', UpdateView.as_view(model=Room, fields="__all__", success_url='/rooms/')), url(r'^room_delete/(?P<pk>[0-9]+)', DeleteView.as_view(model=Room, success_url='/rooms/')), url(r'^rooms/', ListView.as_view(model=Room)),
def get_absolute_url(self): if 'success_url' in self.kwargs: return self.kwargs['success_url'] return CreateView.get_absolute_url(self)
from django.views.generic import CreateView, UpdateView, ListView from forms import FeatureTypeForm, MapForm, LayerForm, MapLayerForm from views import CreateFeatures, create_update_map, FeatureTypeListView, FeatureTypeDelete, MapListView, MapDelete, LayerListView, LayerDelete, LayerImport from models import FeatureType, Map, Layer urlpatterns = patterns( '', url(r'^feature-types/?$', FeatureTypeListView.as_view(queryset=FeatureType.objects.all()), name='feature-type-list'), url(r'^features/create/?$', login_required(CreateFeatures.as_view()), name='feature-create'), url(r'^feature-types/create/?', login_required( CreateView.as_view(template_name='core/generic_form.html', form_class=FeatureTypeForm)), name='feature-type-create'), url(r'^feature-types/update/(?P<pk>\d+)/?$', login_required( UpdateView.as_view( template_name='core/generic_form.html', queryset=FeatureTypeForm.Meta.model.objects.all(), form_class=FeatureTypeForm)), name='feature-type-update'), url(r'^feature-types/delete/(?P<pk>\d+)/?$', login_required(FeatureTypeDelete.as_view()), name='feature-type-delete'), # Map list url(r'^maps/?$', MapListView.as_view(queryset=Map.objects.all()),
from django.conf.urls.static import static from django.contrib.auth.models import User from django.urls import path from django.views.generic import TemplateView, CreateView from app import views from app.forms import RegisterForms urlpatterns = [ path('', TemplateView.as_view(template_name='index.html'), name='home'), path('centre/', TemplateView.as_view(template_name='center.html'), name='centre'), path('about/', TemplateView.as_view(template_name='about.html'), name='about'), path('register/', CreateView.as_view(model=User, form_class=RegisterForms, success_url='/login/'), name='register'), path('accounts/profile/', views.login_page, name='login-page'), path('form-fill/', views.FormFillView.as_view(), name='form-fill'), path('user-detail/<slug>/', views.UserDetailView.as_view(), name='user-detail'), path('hallticket/', views.pdf_generator, name='pdf-generator'), ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
def get(self, request, *args, **kwargs): self.object = self.get_object() if self.object: return redirect(reverse("roommate_search_edit_profile")) return CreateView.get(self, request, *args, **kwargs)
from django.conf.urls.defaults import patterns, include, url from django.views.generic import ListView, DetailView, CreateView from sujets.models import Question from sujets.views import vote, OptionCreateView urlpatterns = patterns('', url(r'^$', ListView.as_view(model=Question)), url(r'^(?P<pk>\d+)/$', DetailView.as_view(model=Question), name='question_detail'), url(r'^new/$', CreateView.as_view(model=Question), name='question_new'), url(r'^(?P<question>\d+)/new/$', OptionCreateView.as_view(), name='option_new'), url(r'^vote/$', vote, name="vote"), )
# abort if request is not made via POST if request.method != 'POST': return HttpResponseNotAllowed(['POST']) # abort if request is not made via ajax if not request.is_ajax(): error = {'error': 'This resource requires ajax requests.'} return JsonResponse(error, status=422) # abort if posted data is not valid form = CustomerForm(request.POST) if not form.is_valid(): error = {'error': form.errors} return JsonResponse(error, status=422) name = form.cleaned_data.get('name') email = form.cleaned_data.get('email') Customer.objects.create(name=name, email=email) message = '{name} ({email}) added.'.format(name=name, email=email) return JsonResponse({'message': message}) person_create = CreateView.as_view( model=Person, form_class=PersonForm, success_url='/person/' ) person_list = ListView.as_view(model=Person)
from django.conf.urls.defaults import * #from views import * from models import * #from django.contrib.auth.decorators import login_required, permission_required from django.views.generic import DetailView, ListView, CreateView, UpdateView urlpatterns = patterns('croquis/', url(r'view/(?P<pk>\d+)/$',DetailView.as_view(model=Topo), name="topo_view"), url(r'new$',CreateView.as_view(model=Topo), name="topo_new"), url(r'$',ListView.as_view(model=Topo), name="topo_index"), )
def render_to_response(self, context): if permissions.can_user_create_page(self.request.user): return CreateView.render_to_response(self, context) else: return HttpResponseForbidden('You do not have permission to access this page.')
from django.contrib.auth.models import User from django.contrib.auth.decorators import login_required from django.db.models import Count, Q, Sum from django.views.generic import ListView, DeleteView, CreateView, UpdateView from sponsor.views import SponsorCreateView, SponsorUpdateView, SponsorEmailingView, sponsorMailPreview, SponsorContactResetEmailView, loadResponseInfoFromRT from sponsor.forms import SponsorContactForm, SponsorPackageForm from sponsor.models import Sponsoring, SponsoringParticipants, SponsorContact, SponsorPackage from sabot.views import ParticipantsView, OwnerSettingCreateView, PermCheckUpdateView, EmailOutputView, XMLListView, MultipleListView, PropertySetterView, PermCheckPropertySetterView, PermCheckSimpleDeleteView, ArchiveCreatorView from sabot.decorators import user_is_staff urlpatterns = patterns('', url(r'^new', user_is_staff(CreateView.as_view( model = SponsorPackage, form_class = SponsorPackageForm, template_name = "sponsor/package/update.html", success_url = "%(id)s")), name = "sponsorpackage_new"), url(r'^(?P<pk>[0-9]+)$', user_is_staff(UpdateView.as_view( model = SponsorPackage, form_class = SponsorPackageForm, template_name = "sponsor/package/update.html", success_url = "list")), name = "sponsorpackage_update"), url(r'^list/?', user_is_staff(ListView.as_view( queryset = SponsorPackage.objects.all(), template_name = "sponsor/package/list.html")), name="sponsorpackage_list"),
from django.views.generic import ListView, CreateView from views import RunsList, ProjectDetail, ProjectImport, ProjectImporter from bsct.urls import URLGenerator from models import Project bsct_patterns_project = URLGenerator(Project).get_urlpatterns(paginate_by=10) urlpatterns = patterns( '', url('^project/$', ListView.as_view(model=Project, template_name="projects/project_list.html"), name='project_list'), url('^project/import/?$', ProjectImport.as_view(), name='project_import'), url('^project/import_add/(?P<repo_id>\d+)?$', ProjectImporter, name='project_import_add'), url('^project/(?P<pk>\d+)$', ProjectDetail.as_view(), name='project_detail'), url('^project/new/?$', CreateView.as_view(model=Project, template_name="projects/project_create.html"), name='project_create'), url('^project/(?P<pk>\d+)/runs$', RunsList.as_view(), name='project_runs_list'), url('', include(bsct_patterns_project)), )
def form_valid(self, form): form.instance.user = self.request.user if form.instance.deadline.date < datetime.date.today(): form.add_error('deadline', 'The Schedule cannot be in the past!') return self.form_invalid(form) return CreateView.form_valid(self, form)
from django.conf.urls import patterns, include, url from django.views.generic import ListView, CreateView, DetailView, UpdateView, DeleteView from django.contrib.staticfiles.urls import staticfiles_urlpatterns from entries.models import Entry from entries.forms import HTML5Form urlpatterns = patterns('', url(r'^$', ListView.as_view( queryset = Entry.objects.order_by('-pub_date'), template_name = 'entries/entry_list.html')), url(r'^create/$', CreateView.as_view( model = Entry, success_url = '/entries/', template_name = 'entries/entry_form.html', form_class = HTML5Form)), url(r'^detail/(?P<pk>\d+)/$', DetailView.as_view( model = Entry, template_name = 'entries/entry_detail.html'), name = "entry_detail"), url(r'^update/(?P<pk>\d+)/$', UpdateView.as_view( model = Entry, template_name = 'entries/entry_form.html', form_class = HTML5Form)), url(r'^delete/(?P<pk>\d+)/$', DeleteView.as_view( model = Entry,
url(r"^print/(?P<pk>\d+)/$", imprimir_hobetuz, name="hobetuz_imprimir"), ## Genericas url(r"thanks/$", direct_to_template, {"template": "hobetuz/gracias.html"}, name="hobetuz_gracias"), # ~ ##Para los cursos url(r"^curso/list/$", login_required(CursoList.as_view()), name="hobetuz_curso_lista"), url( r"^curso/delete/(?P<pk>\d+)/$", login_required(DeleteView.as_view(model=Curso, success_url="/hobetuz/curso/list/")), name="hobetuz_curso_delete", ), url( r"^curso/new/$", login_required( CreateView.as_view( model=Curso, form_class=CursoForm, success_url="/hobetuz/curso/list", template_name="hobetuz/curso_form.html", ) ), name="hobetuz_curso_nuevo", ), url( r"^curso/edit/(?P<pk>\d+)/$", login_required( UpdateView.as_view(model=Curso, success_url="/hobetuz/curso/list", template_name="hobetuz/curso_edit.html") ), name="hobetuz_curso_edit", ), url(r"^/?$", HobetuzPortada.as_view(), name="hobetuz"), )
CourseHole,) from courses.views import (ArenaDetailView, CourseDetailView,) urlpatterns = patterns('', # TODO: Break these out into multiple urlpatterns # Arena url(r'^arenas/$', ListView.as_view( model=Arena, context_object_name="arenas", ), name="golfstats-courses-arenas"), url(r'^arenas/create/$', CreateView.as_view( model=Arena, success_url=reverse_lazy('golfstats-courses-arenas'), ), name="golfstats-courses-arenas-create"), url(r'^arenas/(?P<pk>\d+)/$', ArenaDetailView.as_view( model=Arena, context_object_name="arena", ), name="golfstats-courses-arenas-detail"), url(r'^arenas/(?P<pk>\d+)/edit/', UpdateView.as_view( model=Arena, context_object_name="arena", success_url=reverse_lazy('golfstats-courses-arenas'), ), name="golfstats-courses-arenas-edit"), url(r'^arenas/(?P<pk>\d+)/delete/$', DeleteView.as_view( model=Arena,
post_list = PostListView.as_view() ''' #prefetch 방법 1 post_list = ListView.as_view(model=Post, queryset=Post.objects.all().prefetch_related('tag_set','comment_set') ) ''' #post_list = ListView.as_view(model=Post, paginate_by =10) post_detail = DetailView.as_view(model = Post) ''' #blog/form.py 원래는 여기에다가 form 을 구현 class PostForm(forms.ModelForm): class Meta: model =Post fields = '__all__' class PostCreateView(CreateView): model = Post form_class = PostForm # success_url ='/..' 원래는 이 것을 구현해야한다. 그러나 get_absolute_url이 대신해주고 코드를 간편하게 해준다. post_new = PostCreateView.as_view() ''' post_new = CreateView.as_view(model =Post) post_edit = UpdateView.as_view(model =Post, fields='__all__') post_delete = DeleteView.as_view(model =Post, success_url= reverse_lazy('blog:post_list'))
}) def item_detail(request, pk): item = get_object_or_404(Item, pk=pk) return render(request, 'shop/item_detail.html', { 'item': item, }) # def item_new(request, item=None): # if request.method == 'POST': # form = ItemForm(request.POST, request.FILES, instance=item) # if form.is_valid(): # item = form.save() # ModelForm에서 제공 # return redirect(item) # else: # form = ItemForm(instance=item) # return render(request, 'shop/item_form.html', { # 'form': form, # }) # def item_edit(request, pk): # item = get_object_or_404(Item, pk=pk) # return item_new(request, item) item_new = CreateView.as_view(model=Item, form_class=ItemForm) item_edit = UpdateView.as_view(model=Item, form_class=ItemForm)
from django.conf.urls.defaults import patterns, include, url from django.views.generic import ListView, CreateView from models import Thing from djangoratings.views import AddRatingFromModel from django.core.urlresolvers import reverse urlpatterns = patterns('ratings.views', url(r'^$', ListView.as_view( model=Thing, paginate_by=10 )), url(r'^add/$', CreateView.as_view( model=Thing, success_url='/' )), url(r'^rate/(?P<object_id>\d+)/(?P<score>\d+)/', AddRatingFromModel(), { 'app_label': 'ratings', 'model': 'thing', 'field_name': 'rating', }), )
from django.core.urlresolvers import reverse from models import Coctail, Category, Ingridient from views import (CategoryDelete, IngridientDeleteWithCoctails, IngridientDeleteFromCoctails) qs_coctails = Coctail.objects.all().select_related('ingridients') qs_categories = Category.objects.all().select_related('coctails') qs_ingridients = Ingridient.objects.all() urlpatterns = patterns('', url(r'^coctails$', ListView.as_view(queryset=qs_coctails), name='coctails'), url(r'^coctails/(?P<pk>\d+)$', DetailView.as_view(queryset=qs_coctails), name='coctail'), ) urlpatterns += patterns('', url(r'^categories$', ListView.as_view(model=Category), name='categories'), url(r'^categories/add$', CreateView.as_view(model=Category), name='category_add'), url(r'^categories/(?P<pk>\d+)$', DetailView.as_view(queryset=qs_categories), name='category'), url(r'^categories/(?P<pk>\d+)/edit$', UpdateView.as_view(queryset=qs_categories), name='category_edit'), url(r'^categories/(?P<pk>\d+)/delete$', CategoryDelete.as_view(), name='category_delete'), ) urlpatterns += patterns('', url(r'^ingridients$', ListView.as_view(model=Ingridient), name='ingridients'), url(r'^ingridients/add$', CreateView.as_view(model=Ingridient), name='ingridient_add'), url(r'^ingridients/(?P<pk>\d+)$', DetailView.as_view(queryset=qs_ingridients), name='ingridient'), url(r'^ingridients/(?P<pk>\d+)/edit$', UpdateView.as_view(queryset=qs_ingridients), name='ingridient_edit'), url(r'^ingridients/(?P<pk>\d+)/delete$', IngridientDeleteWithCoctails.as_view(), name='ingridient_delete_with_coctails'), url(r'^ingridients/(?P<pk>\d+)/delete_from_coctails$', IngridientDeleteFromCoctails.as_view(), name='ingridient_delete_from_coctails'), )
from django.core.urlresolvers import reverse_lazy as r from django.shortcuts import render from django.views.generic import CreateView, ListView, DetailView from django.views.generic import UpdateView, DeleteView from .forms import PersonForm from .mixins import NameSearchMixin from .models import Person def home(request): return render(request, 'index.html') class PersonList(NameSearchMixin, ListView): model = Person paginate_by = 5 person_detail = DetailView.as_view(model=Person) person_create = CreateView.as_view(model=Person, form_class=PersonForm) person_update = UpdateView.as_view(model=Person, form_class=PersonForm) person_delete = DeleteView.as_view(model=Person, success_url=r('core:person_list'))
entry_detail = DetailView.as_view(model=Entry) # class EntryActionMixin(object): # @property # def action(self): # msg = "{0} is missing action.".format(self.__class__) # raise NotImplementedError(msg) # def form_valid(self, form): # msg = "Entrada {0}!".format(self.action) # messages.info(self.request, msg) # return super(EntryActionMixin, self).form_valid(form) entry_create = CreateView.as_view(model=Entry, form_class=EntryForm) entry_update = UpdateView.as_view(model=Entry, form_class=EntryForm) class ProposalList(ProposalMixin, ListView): model = Proposal paginate_by = 10 proposal_detail = DetailView.as_view(model=Proposal) # class ProposalDetail(DetailView): # template_name = 'core/proposal/proposal_detail.html' # model = Proposal
'TasksManager.views.connection.page', name="public_connection"), url(r'^logout$', 'TasksManager.views.logout.page', name="public_logout"), url(r'^project-detail-(?P<pk>\d+)$', 'TasksManager.views.project_detail.page', name="project_detail"), url(r'^create-developer$', 'TasksManager.views.create_developer.page', name="create_developer"), url(r'^create-supervisor$', 'TasksManager.views.create_supervisor.page', name="create_supervisor"), url(r'^create_project$', login_required( CreateView.as_view(model=Project, template_name="en/public/create_project.html", success_url='index')), name="create_project"), url(r'^create_task$', CreateView.as_view(model=Task, template_name="en/public/create_task.html", success_url='task_list'), name="create_task"), url(r'^project_list$', Project_list.as_view(), name="project_list"), url(r'^developer_list$', ListView.as_view(model=Developer, template_name="en/public/developer_list.html"), name="developer_list"), # url (r'^developer_detail_(?P<pk>\d+)$', Developer_detail.as_view(), name="developer_detail"), url(r'^update_task_time_(?P<pk>\d+)$', Task_update_time.as_view(),
from django.shortcuts import render from django.contrib.auth.decorators import login_required from django.contrib.auth import get_user_model from django.contrib.auth.forms import UserCreationForm from django.views.generic import CreateView from django.urls import reverse_lazy from shop.models import Order User = get_user_model() signup = CreateView.as_view(model=User, form_class=UserCreationForm, template_name='accounts/signup_form.html', success_url= reverse_lazy('root')) @login_required def profile(request): order_list = Order.objects.filter(user=request.user) return render(request, 'accounts/profile.html', { 'order_list': order_list, })
url(r'^aois/work/(?P<pk>\d+)/comment/?$', add_workcell_comment, name='add-workcell-comment'), url(r'^aois/work/(?P<pk>\d+)/log/?$', LogJSON.as_view(), name='workcell_log'), url(r'^aois/update-status/(?P<pk>\d+)/(?P<status>Unassigned|Assigned|In work|Awaiting review|In review|Completed)/?$', login_required(ChangeAOIStatus.as_view()), name="aoi-update-status"), url(r'^aois/update-priority/(?P<pk>\d+)/?$', login_required(update_priority), name="aoi-update-priority"), url(r'^aois/create/?$', login_required( CreateView.as_view(queryset=AOI.objects.all(), template_name='core/generic_form.html', form_class=AOIForm)), name='aoi-create'), url(r'^aois/update/(?P<pk>\d+)/?$', login_required( UpdateView.as_view(queryset=AOI.objects.all(), template_name='core/generic_form.html', form_class=AOIForm)), name='aoi-update'), url(r'^aois/delete/(?P<pk>\d+)/?$', login_required(AOIDelete.as_view()), name='aoi-delete'), url(r'^aois/deleter/(?P<pk>\d+)/?$', login_required(aoi_delete), name='aoi-deleter'), url(r'^features/delete/(?P<pk>\d+)/?$',
from views import BatchCreateAOIS, CreateFeaturesView, Dashboard, DetailedListView, JobDetailedListView, ChangeAOIStatus urlpatterns = patterns('', url(r'^$', Dashboard.as_view(), name='home'), # PROJECTS url(r'^projects/?$', ListView.as_view(queryset=Project.objects.all()), name='project-list'), url(r'^projects/(?P<pk>\d+)/?$', DetailedListView.as_view(template_name="core/project_detail.html"), name='project-detail'), url(r'^projects/create/?$', CreateView.as_view(form_class=ProjectForm, template_name="core/generic_form.html"), name='project-create'), url(r'^projects/update/(?P<pk>\d+)/?$', UpdateView.as_view(queryset=Project.objects.all(), template_name='core/generic_form.html', form_class=ProjectForm), name='project-update'), # JOBS url(r'^jobs/?$', ListView.as_view(queryset=Job.objects.all()), name='job-list'), url(r'^jobs/(?P<pk>\d+)/(?P<status>[a-zA-Z_ ]+)?/?$', JobDetailedListView.as_view(template_name='core/job_detail.html'), name='job-detail'), url(r'^jobs/create/?$', CreateView.as_view(queryset=Job.objects.all(), template_name='core/generic_form.html',
context_object_name = 'books' paginate_by = 10 def get_context_data(self, **kwargs): context = super(BookList, self).get_context_data(**kwargs) context['count_published'] = Book.objects.published().count() return context class BookDetail(DetailView): model = Book context_object_name = 'book' class BookCreate(CreateView): model = Book form_class = BookForm class BookUpdate(UpdateView): model = Book form_class = BookForm author_list = ListView.as_view(model=Author) author_detail = DetailView.as_view(model=Author) author_create = CreateView.as_view( model=Author, fields=['name'], success_url=r('bookstore:author_list'))
v1_api.register(TripItemRelationshipResource()) v1_api.register(TripUserRelationshipResource()) v1_api.register(PopularItemResource()) urlpatterns = patterns( "", # (r'^$', RedirectView.as_view( # url = 'web/start' # )), (r"^tinymce/", include("tinymce.urls")), (r"^start/$", StartView.as_view(template_name="start.html")), # ------------ Trip Views -------------- (r"^trip/(?P<pk>\d+)/$", TripDetailView.as_view(model=Trip, template_name="trip/detail.html"), "", "detail_trip"), (r"^trip/$", ListView.as_view(model=Trip, template_name="trip/list.html")), ( r"^trip/create/$", login_required( TripCreateView.as_view(form_class=TripForm, template_name="trip/create.html", success_url="/web/trip/") ), ), # ------------ Item Views -------------- (r"^item/$", ListView.as_view(model=Item, template_name="item/list.html")), (r"^item/(?P<pk>\d+)/$", DetailView.as_view(model=Item, template_name="item/detail.html")), ( r"^item/create/$", login_required(CreateView.as_view(form_class=ItemForm, template_name="item/create.html", success_url="/")), ), # ------------ Api Views -------------- (r"^", include(v1_api.urls)), )
from django.shortcuts import render, get_object_or_404 from django.views.generic import ListView, DetailView, CreateView from .models import Author, Book from .forms import AuthorForm, BookForm author_list = ListView.as_view(model=Author) author_detail = DetailView.as_view(model=Author) author_new = CreateView.as_view(model=Author, form_class=AuthorForm, template_name='testmodelform/author_form.html') book_list = ListView.as_view(model=Book) book_detail = DetailView.as_view(model=Book) book_new = CreateView.as_view(model=Book, form_class=BookForm, template_name='testmodelform/book_form.html')
def post_new(request): if request.method =='POST': form = PostForm(request.POST) if form.is_valid(): post = form.save() return redirect(post) # return redirect('blog:post_detail', post.pk) else : form = PostForm() return render(request, 'blog/post_form.html', { 'form':form, }) #upgrade version. overwirte post_new = CreateView.as_view(model=Post, form_class=PostForm) def comment_new(request, post_pk): if request.method =='POST': form = CommentForm(request.POST) if form.is_valid(): comment = form.save(commit=False) #innerside, do not run model instance 'save' function comment.post = Post.objects.get(pk=post_pk) #add post _ id comment.save() return redirect('blog:post_detail', comment.post.pk) else :
from django.conf.urls import include, url from django.views.generic import RedirectView from django.contrib import admin from django.contrib.auth.forms import UserCreationForm from django.views.generic import CreateView from urlshortner.models import Bookmark from urlshortner.views import home, CreateBookMark, BookmarkUpdate, BookmarkDelete, profile, wtd, wtupdate, redirec, \ ouser, allbookmarks urlpatterns = [ url(r'^api/', include('url_api.urls')), url('^register/', CreateView.as_view( template_name='registration/create_user.html', form_class=UserCreationForm, success_url='/profile/'), name="regis"), url(r'^admin/', include(admin.site.urls)), url(r'^login/$', 'django.contrib.auth.views.login',name="login"), url(r'^logout', 'django.contrib.auth.views.logout', name="logout"), url('^Bookmark/', CreateBookMark.as_view( template_name='createbookmark.html', success_url='/profile/'), name="createbookmark"), url(r'^wtd/', wtd, name="wtd"), url(r'^uwtupdate/', wtupdate, name="wtupdate"), url(r'^profile/', profile, name="profile"),
#path('foto/reportepdf/<filtro>/', fotos.Reportefototipo.pdf_Platypus, name='reportepdf'), path('foto/reportepdf/<filtro>/', fotos.FotoportipoPdf.as_view(), name='reportepdf'), #path('foto/reportepdf/<filtro>/', fotos.Pdf.as_view(), name='reportepdf'), #path('foto/reportepdf/<filtro>/', fotos.Reportefototipo.pdf_Platypus, name='reportepdf'), path('foto/reporte_fotos_excel/<filtro>/', fotos.ReporteFotosExcel.excel_openpyxl, name="reporte_fotos_excel"), #url(r'^foto/reporte_fotos_excel/(\w+)/$', fotos.ReporteFotosExcel.as_view(), name="reporte_fotos_excel"), path('tipofoto/listar', ListView.as_view(model=Tipofoto, template_name="listartipo.html"), name='lista_tipo_foto'), path('tipofoto/crear', CreateView.as_view(form_class=TipoFotoForm, template_name="fotos/formulariotipofoto.html", model=Tipofoto), name='tipofoto-crear'), path('tipofoto/actualiza/<pk>/', UpdateView.as_view(form_class=TipoFotoForm, template_name="fotos/formulariotipofoto.html", model=Tipofoto), name='tipofoto-actualiza'), path('tipofoto/elimina/<pk>/', fotos.Eliminatipofoto.as_view(), name='tipofoto-eliminar'), path('procedencia/listar', ListView.as_view(model=Procedencia, template_name="listarprocedencia.html"), name='lista_procedencia'), path('procedencia/crear',
name='job-create-aois'), url(r'^jobs/(?P<job_pk>\d+)/batch-create-aois/?$', #login required set in views 'core.views.batch_create_aois', name='job-batch-create-aois'), # AOIS url(r'^aois/(?P<status>[a-zA-Z_ ]+)?/?$', AOIDetailedListView.as_view(template_name='core/aoi_list.html'), name='aoi-list'), url(r'^aois/work/(?P<pk>\d+)/?$', login_required(CreateFeaturesView.as_view()), name='aoi-work'), url(r'^aois/update-status/(?P<pk>\d+)/(?P<status>Unassigned|Assigned|In work|In review|Completed)/?$', login_required( ChangeAOIStatus.as_view()), name="aoi-update-status"), url(r'^aois/create/?$', login_required( CreateView.as_view(queryset=AOI.objects.all(), template_name='core/generic_form.html', form_class=AOIForm)), name='aoi-create'), url(r'^aois/update/(?P<pk>\d+)/?$', login_required( UpdateView.as_view(queryset=AOI.objects.all(), template_name='core/generic_form.html', form_class=AOIForm)), name='aoi-update'), url(r'^aois/delete/(?P<pk>\d+)/?$', login_required( AOIDelete.as_view()), name='aoi-delete'), url(r'^aois/deleter/(?P<pk>\d+)/?$', login_required( aoi_delete ), name='aoi-deleter'), url(r'^features/delete/(?P<pk>\d+)/?$', login_required( feature_delete ), name='feature-delete'),
import account.views from customer.models import Customer # admin.autodiscover() urlpatterns = patterns('', url(r'^$', account.views.index, name='index'), url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'account/login.html'}, name='login'), url(r'^logout/$', account.views.logout, name='logout'), url(r'^main/$', account.views.index, name='main'), url(r'^customers/$', login_required(ListView.as_view( queryset=Customer.objects.order_by("name").all())), name='customers'), url(r'^customers/new/$', login_required(CreateView.as_view( model=Customer, success_url="/customers/%(id)s/")), name='new_customer'), # Examples: # url(r'^$', 'workshop.views.home', name='home'), # url(r'^workshop/', include('workshop.foo.urls')), # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: # url(r'^admin/', include(admin.site.urls)), )
urlpatterns = patterns('', url(r'^feature-types/?$', FeatureTypeListView.as_view(queryset=FeatureType.objects.all()), name='feature-type-list'), url(r'^features/create/?$', login_required(CreateFeatures.as_view()), name='feature-create'), url(r'^features/edit/?$', login_required(EditFeatures.as_view()), name='feature-edit'), url(r'^feature-types/create/?', login_required(CreateView.as_view(template_name='core/generic_form.html', form_class=FeatureTypeForm)), name='feature-type-create'), url(r'^feature-types/update/(?P<pk>\d+)/?$', login_required(UpdateView.as_view(template_name='core/generic_form.html', queryset=FeatureTypeForm.Meta.model.objects.all(), form_class=FeatureTypeForm)), name='feature-type-update'), url(r'^feature-types/delete/(?P<pk>\d+)/?$', login_required(FeatureTypeDelete.as_view()), name='feature-type-delete'), # Map list url(r'^maps/?$', MapListView.as_view(queryset=Map.objects.all()), name='map-list'),