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 { ...@@ -59,27 +59,13 @@ class DebugCRUD extends React.Component {
/> />
<h3>Read</h3> <h3>Read</h3>
<Formik
initialValues={{ email: "", password: "" }} {this.state.AllGoLinks.map(golink => (
validationSchema={SignupSchema} <li key={golink.short}>
onSubmit={(values, { setSubmitting }) => { <a href={`/${golink.short}`}> /{golink.short}</a> |{" "}
setTimeout(() => { {golink.destination}
console.log(JSON.stringify(values, null, 2)); </li>
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>
)}
/>
<h3>Update</h3> <h3>Update</h3>
<Formik <Formik
......
...@@ -23,10 +23,10 @@ class URLPermission(permissions.BasePermission): ...@@ -23,10 +23,10 @@ class URLPermission(permissions.BasePermission):
message = "You do not have the necessary approvals to perform that action." message = "You do not have the necessary approvals to perform that action."
def has_permission(self, request, view): 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): 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): class URLViewSet(viewsets.ModelViewSet):
...@@ -40,9 +40,7 @@ class URLViewSet(viewsets.ModelViewSet): ...@@ -40,9 +40,7 @@ class URLViewSet(viewsets.ModelViewSet):
lookup_field = "short" lookup_field = "short"
def get_queryset(self): def get_queryset(self):
if not self.request.user.is_staff: return URL.objects.filter(owner=self.request.user.registereduser)
return URL.objects.filter(owner=self.request.user.registereduser)
return URL.objects.all()
def perform_create(self, serializer): def perform_create(self, serializer):
serializer.save(owner=self.request.user.registereduser) 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