diff options
author | luxagraf <sng@luxagraf.net> | 2023-07-24 13:38:44 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2023-07-24 13:38:44 -0500 |
commit | e5c5a6c840456a46e894f765c5e438692c810d5d (patch) | |
tree | 27898ded1212afc109db2566d609e7b0d7346234 /app | |
parent | efcc50c5ecff2b62b80f0621752e2098014f9b08 (diff) |
posts: removed old notes model
Diffstat (limited to 'app')
-rw-r--r-- | app/posts/admin.py | 22 | ||||
-rw-r--r-- | app/posts/forms.py | 15 | ||||
-rw-r--r-- | app/posts/models.py | 28 | ||||
-rw-r--r-- | app/posts/views.py | 41 |
4 files changed, 2 insertions, 104 deletions
diff --git a/app/posts/admin.py b/app/posts/admin.py index abe5a5c..9e5b4e8 100644 --- a/app/posts/admin.py +++ b/app/posts/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from .models import Post, Note +from .models import Post from utils.widgets import AdminImageWidget, LGEntryForm from django.contrib.auth.models import User @@ -19,23 +19,3 @@ class PostAdmin(admin.ModelAdmin): css = { "all": ("my_styles.css",) } - - -@admin.register(Note) -class NoteAdmin(admin.ModelAdmin): - def get_form(self, request, obj=None, change=False, **kwargs): - form = super().get_form(request, obj=obj, change=change, **kwargs) - form.base_fields['post'].queryset = Post.objects.filter( - user=request.user - ) - return form - - list_display = ('date_created', 'title', 'post') - search_fields = ['title'] - list_filter = ['date_created'] - - class Media: - js = ('image-loader.js', 'next-prev-links.js') - css = { - "all": ("my_styles.css",) - } diff --git a/app/posts/forms.py b/app/posts/forms.py deleted file mode 100644 index 5cde108..0000000 --- a/app/posts/forms.py +++ /dev/null @@ -1,15 +0,0 @@ -from django.forms import ModelForm - -from .models import Note -from posts.models import Post - -class NoteCreateForm(ModelForm): - - def __init__(self,*args,**kwargs): - user = kwargs.pop('user') - super(NoteCreateForm,self).__init__(*args,**kwargs) - self.fields['post'].queryset = Post.objects.filter(user=user).order_by("title") - - class Meta: - model = Note - fields = ['title', 'url', 'body_markdown', 'post'] diff --git a/app/posts/models.py b/app/posts/models.py index 0d1acf9..e2adb0a 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -91,34 +91,6 @@ class Post(models.Model): self.needs_update = False super(Post, self).save() - -class Note(models.Model): - user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL, related_name="olduser") - title = models.CharField(max_length=400) - url = models.CharField(max_length=400, blank=True, null=True) - body_markdown = models.TextField(blank=True, null=True) - date_created = models.DateTimeField(default=timezone.now) - post = models.ForeignKey(Post, on_delete=models.CASCADE, null=True, related_name="oldpost") - STATUS = ( - (0, 'Call In'), - (1, 'Coming'), - (2, 'Testing'), - (3, 'Done'), - (4, 'Live'), - ) - status = models.IntegerField(choices=STATUS, default=0) - - class Meta: - ordering = ('date_created',) - - def __str__(self): - return self.title - - def get_absolute_url(self): - return reverse('notes:edit', kwargs={"pk": self.pk}) - - def save(self, *args, **kwargs): - super(Note, self).save() #URL,This Article,Type,Lead,Previous Leads,Other Testers,Notes/Docs,Last Pub Date,Update Next,Months Since Update,Update Frequency (Months),Updates per year,Prev. Updates,"18 Mo Traffic Trend ''' row[0] #url diff --git a/app/posts/views.py b/app/posts/views.py index 6a5ff95..3c25483 100644 --- a/app/posts/views.py +++ b/app/posts/views.py @@ -4,8 +4,7 @@ from django.utils.decorators import method_decorator from django.contrib.auth.decorators import login_required from django.urls import reverse -from .models import Post, Note -from .forms import NoteCreateForm +from .models import Post class PostListView(ListView): @@ -22,44 +21,6 @@ class PostListView(ListView): class PostNotesView(DetailView): model = Post - -class NoteCreateView(CreateView): - model = Note - form_class = NoteCreateForm - - def get_form_kwargs(self): - kwargs = super(NoteCreateView, self).get_form_kwargs() - kwargs.update({'user': self.request.user}) - return kwargs - - def get_success_url(self): - return reverse('posts:detail', kwargs={"pk": self.object.post.pk}) - - -class NoteUpdateView(UpdateView): - model = Note - fields = ['title', 'url', 'body_markdown', 'post', 'status', 'user'] - - def get_context_data(self, **kwargs): - context = super(NoteUpdateView, self).get_context_data(**kwargs) - context['is_update'] = True - return context - - def get_success_url(self): - return reverse('posts:detail', kwargs={"pk": self.object.post.pk}) - - -class NoteListView(ListView): - model = Note - - def get_queryset(self): - if self.kwargs['status'] == "todo": - status = "Call In" - else: - status = self.kwargs['status'] - status_reverse = dict((v, k) for k, v in Note.STATUS) - return Note.objects.filter(user=self.request.user).filter(status=status_reverse[status]) - ''' class UpdateViewWithUser(UpdateView): |