Commit 45271a66 authored by David Haynes's avatar David Haynes 🙆

Reading go links into react works

- rendering to the page in a basic manner.
- need to abstract into it's own component
parent 3749c917
Pipeline #3568 passed with stage
in 1 minute and 1 second
......@@ -59,27 +59,13 @@ class DebugCRUD extends React.Component {
/>
<h3>Read</h3>
<Formik
initialValues={{ email: "", password: "" }}
validationSchema={SignupSchema}
onSubmit={(values, { setSubmitting }) => {
setTimeout(() => {
console.log(JSON.stringify(values, null, 2));
setSubmitting(false);
}, 400);
}}
render={({ isSubmitting }) => (
<Form>
<Field type="email" name="email" placeholder="Email" />
<ErrorMessage name="email" component="div" />
<Field type="password" name="password" />
<ErrorMessage name="password" />
<button type="submit" disabled={isSubmitting}>
Submit
</button>
</Form>
)}
/>
{this.state.AllGoLinks.map(golink => (
<li key={golink.short}>
<a href={`/${golink.short}`}> /{golink.short}</a> |{" "}
{golink.destination}
</li>
))}
<h3>Update</h3>
<Formik
......
......@@ -23,10 +23,10 @@ class URLPermission(permissions.BasePermission):
message = "You do not have the necessary approvals to perform that action."
def has_permission(self, request, view):
return request.user.registereduser.approved or request.user.is_staff
return True
def has_object_permission(self, request, view, obj):
return obj.owner == request.user.registereduser or request.user.is_staff
return obj.owner == request.user.registereduser
class URLViewSet(viewsets.ModelViewSet):
......@@ -40,9 +40,7 @@ class URLViewSet(viewsets.ModelViewSet):
lookup_field = "short"
def get_queryset(self):
if not self.request.user.is_staff:
return URL.objects.filter(owner=self.request.user.registereduser)
return URL.objects.all()
return URL.objects.filter(owner=self.request.user.registereduser)
def perform_create(self, serializer):
serializer.save(owner=self.request.user.registereduser)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment