diff options
author | luxagraf <sng@luxagraf.net> | 2023-07-24 13:07:35 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2023-07-24 13:07:35 -0500 |
commit | 9b7ef91927a6133191878d0454e657a9d5e35083 (patch) | |
tree | 2668465adec096e32419435cf6731d128ca7531b | |
parent | 484ce7f0d996500796617f61e158b6d27150dcff (diff) |
posts: made a todo view so I can see what I need to call in
-rw-r--r-- | app/posts/migrations/0013_note_user_alter_note_status.py | 26 | ||||
-rw-r--r-- | app/posts/models.py | 1 | ||||
-rw-r--r-- | app/posts/note_urls.py | 10 | ||||
-rw-r--r-- | app/posts/templates/posts/note_list.html | 15 | ||||
-rw-r--r-- | app/posts/views.py | 15 | ||||
-rw-r--r-- | config/settings.py | 21 | ||||
-rw-r--r-- | templates/base.html | 2 |
7 files changed, 87 insertions, 3 deletions
diff --git a/app/posts/migrations/0013_note_user_alter_note_status.py b/app/posts/migrations/0013_note_user_alter_note_status.py new file mode 100644 index 0000000..7902f81 --- /dev/null +++ b/app/posts/migrations/0013_note_user_alter_note_status.py @@ -0,0 +1,26 @@ +# Generated by Django 4.2.2 on 2023-07-24 17:41 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('posts', '0012_note_status'), + ] + + operations = [ + migrations.AddField( + model_name='note', + name='user', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL), + ), + migrations.AlterField( + model_name='note', + name='status', + field=models.IntegerField(choices=[(0, 'Call In'), (1, 'Coming'), (2, 'Testing'), (3, 'Done'), (4, 'Live')], default=0), + ), + ] diff --git a/app/posts/models.py b/app/posts/models.py index d9a4236..a3cb3af 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -93,6 +93,7 @@ class Post(models.Model): class Note(models.Model): + user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL) title = models.CharField(max_length=400) url = models.CharField(max_length=400, blank=True, null=True) body_markdown = models.TextField(blank=True, null=True) diff --git a/app/posts/note_urls.py b/app/posts/note_urls.py index 4bf6914..94a030e 100644 --- a/app/posts/note_urls.py +++ b/app/posts/note_urls.py @@ -7,10 +7,20 @@ app_name = "notes" urlpatterns = [ path( r'', + views.NoteListView.as_view(), + name="list" + ), + path( + r'create', views.NoteCreateView.as_view(), name="create" ), path( + r'<str:status>', + views.NoteListView.as_view(), + name="todo" + ), + path( r'<pk>/edit', views.NoteUpdateView.as_view(), name="edit" diff --git a/app/posts/templates/posts/note_list.html b/app/posts/templates/posts/note_list.html new file mode 100644 index 0000000..f1f585b --- /dev/null +++ b/app/posts/templates/posts/note_list.html @@ -0,0 +1,15 @@ +{% extends 'base.html' %} +{% block primary %} +<main class="post-detail"> + <div class="note-list">{% for object in object_list %}<article> + <h2>{%if object.url%}<a href="{{object.url}}">{{object.title}}</a>{%else%}{{object.title}}{%endif%}<span class="note-edit"><a href="{{object.get_absolute_url}}">edit</a></span></h2> + <p>For: <a href="/post/{{object.post.pk}}/notes">{{object.post}}</a></p> + <p>{{object.body_markdown}}</p> + </article> +{% endfor%}</div> +</main> + + +{% endblock %} +{% block js %} +{% endblock%} diff --git a/app/posts/views.py b/app/posts/views.py index e1af9b5..6a5ff95 100644 --- a/app/posts/views.py +++ b/app/posts/views.py @@ -38,7 +38,7 @@ class NoteCreateView(CreateView): class NoteUpdateView(UpdateView): model = Note - fields = ['title', 'url', 'body_markdown', 'post', 'status'] + fields = ['title', 'url', 'body_markdown', 'post', 'status', 'user'] def get_context_data(self, **kwargs): context = super(NoteUpdateView, self).get_context_data(**kwargs) @@ -47,6 +47,19 @@ class NoteUpdateView(UpdateView): 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): diff --git a/config/settings.py b/config/settings.py index 3808f20..69627d5 100644 --- a/config/settings.py +++ b/config/settings.py @@ -25,10 +25,23 @@ SECRET_KEY = 'django-insecure-h8hp$ne=mq*!4y9*q9kes@0_iik2&coksbs$+rkmn^ui28v!v8 # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = ['10.153.93.177',] +ALLOWED_HOSTS = ['10.153.93.178',] +INTERNAL_IPS = [ + "127.0.0.1", + '10.153.93.178', +] +def show_toolbar(request): + return True +DEBUG_TOOLBAR_CONFIG = { + "SHOW_TOOLBAR_CALLBACK" : show_toolbar, +} STATIC_ROOT = os.path.join(BASE_DIR, 'static/') +STATIC_URL = 'static/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') +MEDIA_URL = '/media/' + +AUTH_USER_MODEL = 'auth.User' # Application definition @@ -41,13 +54,17 @@ DJANGO_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sitemaps', + 'django.contrib.humanize' ] THIRD_PARTY_APPS = [ 'django_extensions', + 'debug_toolbar', 'django_admin_listfilter_dropdown', ] LOCAL_APPS = [ 'deals', + 'posts', + 'products' ] INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS @@ -60,6 +77,7 @@ MIDDLEWARE = [ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'debug_toolbar.middleware.DebugToolbarMiddleware', ] ROOT_URLCONF = 'config.base_urls' @@ -131,7 +149,6 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.2/howto/static-files/ -STATIC_URL = 'static/' # Default primary key field type # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field diff --git a/templates/base.html b/templates/base.html index cca6bf3..c771084 100644 --- a/templates/base.html +++ b/templates/base.html @@ -21,6 +21,8 @@ </div> <nav> <a class="nav-item" href="/posts" title="View Guides">Guides</a> + <a class="nav-item" href="/notes/todo" title="See what needs to be called in">Todo</a> + <a class="nav-item" href="/notes" title="View Guides">Notes</a> </nav> </header> {% block breadcrumbs %}{% endblock %} |