summaryrefslogtreecommitdiffstats
path: root/statuses/views
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-05 14:17:27 -0600
committerAndrew Godwin2022-11-05 14:17:27 -0600
commitd77dcf62b4005a0f36ef2fa7ba6d3651d2ef38d7 (patch)
treedd356a933b8179a22e5da6e938acd96a175ac0d6 /statuses/views
downloadtakahe-d77dcf62b4005a0f36ef2fa7ba6d3651d2ef38d7.tar.gz
takahe-d77dcf62b4005a0f36ef2fa7ba6d3651d2ef38d7.tar.bz2
takahe-d77dcf62b4005a0f36ef2fa7ba6d3651d2ef38d7.zip
Initial commit (users and statuses)
Diffstat (limited to 'statuses/views')
-rw-r--r--statuses/views/__init__.py0
-rw-r--r--statuses/views/home.py35
2 files changed, 35 insertions, 0 deletions
diff --git a/statuses/views/__init__.py b/statuses/views/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/statuses/views/__init__.py
diff --git a/statuses/views/home.py b/statuses/views/home.py
new file mode 100644
index 0000000..b9b98d2
--- /dev/null
+++ b/statuses/views/home.py
@@ -0,0 +1,35 @@
+from django import forms
+from django.shortcuts import redirect
+from django.utils.decorators import method_decorator
+from django.views.generic import FormView
+
+from core.forms import FormHelper
+from statuses.models import Status
+from users.decorators import identity_required
+
+
+@method_decorator(identity_required, name="dispatch")
+class Home(FormView):
+
+ template_name = "statuses/home.html"
+
+ class form_class(forms.Form):
+ text = forms.CharField()
+
+ helper = FormHelper(submit_text="Post")
+
+ def get_context_data(self):
+ context = super().get_context_data()
+ context.update(
+ {
+ "statuses": self.request.identity.statuses.all()[:100],
+ }
+ )
+ return context
+
+ def form_valid(self, form):
+ Status.create_local(
+ identity=self.request.identity,
+ text=form.cleaned_data["text"],
+ )
+ return redirect(".")