brucestull / technology-and-perceptibility

Accessible web application with data storage, analysis, and presentation.
GNU General Public License v3.0
0 stars 1 forks source link

Anonymous user views public links. #215

Closed brucestull closed 2 years ago

brucestull commented 2 years ago

Had some issues with migrations on branch for https://github.com/brucestull/technology-and-perceptibility/issues/206.

Issues were caused by merge conflict when merging main into the feature branch.

Creating this new Issue to implement the functionality.

brucestull commented 2 years ago

Need to decide when to load these and what other links need to be cleared.

brucestull commented 2 years ago

Research: https://www.django-rest-framework.org/api-guide/permissions/#isauthenticated https://docs.djangoproject.com/en/4.0/ref/contrib/auth/#django.contrib.auth.models.User.is_authenticated

brucestull commented 2 years ago

This change may end up being superseded by https://github.com/brucestull/technology-and-perceptibility/issues/217. We'll keep the branch for now and continue the changes as a learning exercise.

brucestull commented 2 years ago

Using vanilla Django:

views.py

from .models import Chirp
class ChirpListView(ListView):
    """
    Inherits 'ListView'. View is used to list the Chirps. We can use 'chirp_list' and 'object_list' to get the queryset in the list template.
    """
    model = Chirp
    template_name = 'home.html'

urls.py

from . import views
app_name = 'chirps'
urlpatterns = [
    ...
    path('', views.ChirpListView.as_view(), name='home'),
    ...
]