from django.contrib.auth.mixins import LoginRequiredMixin
from django.shortcuts import render, get_object_or_404
from django.views.generic import CreateView, UpdateView, DeleteView
from django.urls import reverse_lazy, reverse
from .mixins import FormUserNeededMixin, UserOwnerMixin
from .forms import TweetModelForm
from .models import Tweet
# Create your views here.



class TweetCreateView(FormUserNeededMixin,CreateView):
	form_class = TweetModelForm
	template_name = 'tweets/create_view.html'
	# success_url = reverse_lazy("tweet:detail")


class TweetUpdateView(LoginRequiredMixin, UserOwnerMixin, UpdateView):
	queryset = Tweet.objects.all()
	form_class = TweetModelForm
	# success_url = "/tweet/"
	template_name = "tweets/update_view.html"


class TweetDeleteView(DeleteView):
	model = Tweet
	template_name = "tweets/delete_view.html"
	success_url = reverse_lazy("tweet:list")


def tweet_detail_view(request, pk=None):
	obje = get_object_or_404(Tweet, pk=pk)
	print(obje)
	print(request.user)
	context = {
		"objc": obje 
	}
	return render(request, 'tweets/detail_view.html', context)




def tweet_list_view(request):
	obj = Tweet.objects.all()
	print(obj)
	print(request.user)
	context = {

		"object": obj
	}
	return render(request, 'tweets/list_view.html', context)


b283db745851e27b5d76702d1e0ff1d3ad40c805
<mask token>


class TweetUpdateView(LoginRequiredMixin, UserOwnerMixin, UpdateView):
    queryset = Tweet.objects.all()
    form_class = TweetModelForm
    template_name = 'tweets/update_view.html'


class TweetDeleteView(DeleteView):
    model = Tweet
    template_name = 'tweets/delete_view.html'
    success_url = reverse_lazy('tweet:list')


<mask token>

<mask token>


class TweetCreateView(FormUserNeededMixin, CreateView):
    form_class = TweetModelForm
    template_name = 'tweets/create_view.html'


class TweetUpdateView(LoginRequiredMixin, UserOwnerMixin, UpdateView):
    queryset = Tweet.objects.all()
    form_class = TweetModelForm
    template_name = 'tweets/update_view.html'


class TweetDeleteView(DeleteView):
    model = Tweet
    template_name = 'tweets/delete_view.html'
    success_url = reverse_lazy('tweet:list')


<mask token>

<mask token>


class TweetCreateView(FormUserNeededMixin, CreateView):
    form_class = TweetModelForm
    template_name = 'tweets/create_view.html'


class TweetUpdateView(LoginRequiredMixin, UserOwnerMixin, UpdateView):
    queryset = Tweet.objects.all()
    form_class = TweetModelForm
    template_name = 'tweets/update_view.html'


class TweetDeleteView(DeleteView):
    model = Tweet
    template_name = 'tweets/delete_view.html'
    success_url = reverse_lazy('tweet:list')


def tweet_detail_view(request, pk=None):
    obje = get_object_or_404(Tweet, pk=pk)
    print(obje)
    print(request.user)
    context = {'objc': obje}
    return render(request, 'tweets/detail_view.html', context)


<mask token>

from django.contrib.auth.mixins import LoginRequiredMixin
from django.shortcuts import render, get_object_or_404
from django.views.generic import CreateView, UpdateView, DeleteView
from django.urls import reverse_lazy, reverse
from .mixins import FormUserNeededMixin, UserOwnerMixin
from .forms import TweetModelForm
from .models import Tweet


class TweetCreateView(FormUserNeededMixin, CreateView):
    form_class = TweetModelForm
    template_name = 'tweets/create_view.html'


class TweetUpdateView(LoginRequiredMixin, UserOwnerMixin, UpdateView):
    queryset = Tweet.objects.all()
    form_class = TweetModelForm
    template_name = 'tweets/update_view.html'


class TweetDeleteView(DeleteView):
    model = Tweet
    template_name = 'tweets/delete_view.html'
    success_url = reverse_lazy('tweet:list')


def tweet_detail_view(request, pk=None):
    obje = get_object_or_404(Tweet, pk=pk)
    print(obje)
    print(request.user)
    context = {'objc': obje}
    return render(request, 'tweets/detail_view.html', context)


def tweet_list_view(request):
    obj = Tweet.objects.all()
    print(obj)
    print(request.user)
    context = {'object': obj}
    return render(request, 'tweets/list_view.html', context)

from django.contrib.auth.mixins import LoginRequiredMixin
from django.shortcuts import render, get_object_or_404
from django.views.generic import CreateView, UpdateView, DeleteView
from django.urls import reverse_lazy, reverse
from .mixins import FormUserNeededMixin, UserOwnerMixin
from .forms import TweetModelForm
from .models import Tweet
# Create your views here.



class TweetCreateView(FormUserNeededMixin,CreateView):
	form_class = TweetModelForm
	template_name = 'tweets/create_view.html'
	# success_url = reverse_lazy("tweet:detail")


class TweetUpdateView(LoginRequiredMixin, UserOwnerMixin, UpdateView):
	queryset = Tweet.objects.all()
	form_class = TweetModelForm
	# success_url = "/tweet/"
	template_name = "tweets/update_view.html"


class TweetDeleteView(DeleteView):
	model = Tweet
	template_name = "tweets/delete_view.html"
	success_url = reverse_lazy("tweet:list")


def tweet_detail_view(request, pk=None):
	obje = get_object_or_404(Tweet, pk=pk)
	print(obje)
	print(request.user)
	context = {
		"objc": obje 
	}
	return render(request, 'tweets/detail_view.html', context)




def tweet_list_view(request):
	obj = Tweet.objects.all()
	print(obj)
	print(request.user)
	context = {

		"object": obj
	}
	return render(request, 'tweets/list_view.html', context)

