-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c118c9
commit 2d5fbb5
Showing
19 changed files
with
4,514 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<template> | ||
<p>hello</p> | ||
<!-- <div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 id="SaveDocumentModalTitle" class="modal-title"> | ||
{{ $t('Where do you want to save your document?') }} | ||
</h5> | ||
<button | ||
type="button" | ||
class="btn-close" | ||
data-bs-dismiss="modal" | ||
aria-label="Close" | ||
/> | ||
</div> | ||
<div class="modal-body"> | ||
<form | ||
id="save-document-form" | ||
ref="form" | ||
method="post" | ||
> | ||
<div v-if="collections.length"> | ||
<div v-for="collection in collections" :key="collection" class="form-check"> | ||
<input | ||
:id="collection" | ||
class="form-check-input" | ||
type="radio" | ||
:v-model="saveTo" | ||
:value="collection" | ||
> | ||
<label class="form-check-label" :for="collection"> | ||
{{ collection }} | ||
</label> | ||
</div> | ||
</div> | ||
<div> | ||
<div class="form-check"> | ||
<input | ||
id="noCollection" | ||
class="form-check-input" | ||
type="radio" | ||
:v-model="saveTo" | ||
value="noCollection" | ||
> | ||
<label class="form-check-label" for="noCollection"> | ||
{% trans "Don't save to a collection" %} | ||
</label> | ||
</div> | ||
<div class="form-check"> | ||
<input | ||
id="newCollection" | ||
class="form-check-input" | ||
type="radio" | ||
:v-model="saveTo" | ||
value="newCollection" | ||
> | ||
<label class="form-check-label" for="newCollection"> | ||
Create new collection | ||
</label> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> --> | ||
</template> | ||
|
||
<script> | ||
import { authHeaders } from '../api'; | ||
export default { | ||
name: 'SaveDocumentModal', | ||
props: { | ||
collections: { | ||
type: Array, | ||
default: () => [] | ||
} | ||
}, | ||
data () { | ||
return { | ||
saveTo: '' | ||
}; | ||
}, | ||
methods: { | ||
onShow () { | ||
this.saveTo = ''; | ||
}, | ||
async onSubmit () { | ||
const form = new FormData(this.$refs.form); | ||
fetch('/document-problem/', { | ||
method: 'post', | ||
body: form, | ||
headers: await authHeaders() | ||
}) | ||
.then((response) => { | ||
this.submitted = true; | ||
this.success = response.ok; | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
} | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import os | ||
|
||
from django.contrib.auth import get_user_model | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from .core_document_model import CoreDocument | ||
|
||
User = get_user_model() | ||
|
||
|
||
def file_location(instance, filename): | ||
filename = os.path.basename(filename) | ||
return f"{instance.SAVE_FOLDER}/{instance.pk}/{filename}" | ||
|
||
|
||
class Collection(models.Model): | ||
name = models.CharField(_("name"), max_length=1024, unique=True) | ||
user_profile = models.ForeignKey( | ||
"peachjam.UserProfile", | ||
on_delete=models.CASCADE, | ||
verbose_name=_("user_profile"), | ||
related_name="collections", | ||
) | ||
|
||
class Meta: | ||
ordering = ("name",) | ||
verbose_name = _("collection") | ||
verbose_name_plural = _("collections") | ||
|
||
def __str__(self): | ||
return f"{self.name}" | ||
|
||
|
||
class SavedDocument(models.Model): | ||
document = models.ForeignKey(CoreDocument, on_delete=models.CASCADE) | ||
user_profile = models.ForeignKey( | ||
"peachjam.UserProfile", | ||
on_delete=models.CASCADE, | ||
verbose_name=_("user_profile"), | ||
related_name="saved_documents", | ||
) | ||
collection = models.ForeignKey( | ||
Collection, | ||
on_delete=models.CASCADE, | ||
verbose_name=_("collection"), | ||
) | ||
|
||
class Meta: | ||
ordering = ("document__title",) | ||
verbose_name = _("saved document") | ||
verbose_name_plural = _("saved documents") | ||
|
||
def __str__(self): | ||
return f"{self.document.title}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{% extends "allauth/layouts/base.html" %} | ||
{% load account socialaccount static %} | ||
{% load i18n %} | ||
{% block title %} | ||
{% trans 'Sign Up' %} | ||
{% endblock %} | ||
{% block head-css %} | ||
{{ block.super }} | ||
<link href="https://fonts.googleapis.com/css?family=Roboto" | ||
rel="stylesheet"/> | ||
{% endblock %} | ||
{% block content %} | ||
<h1 class="mb-3">{% trans 'Sign up' %}</h1> | ||
<form method="post"> | ||
{% csrf_token %} | ||
{% if form.non_field_errors %} | ||
<div class="text-danger"> | ||
{% for error in form.non_field_errors %}<p>{{ error }}</p>{% endfor %} | ||
</div> | ||
{% endif %} | ||
<div class="form-group"> | ||
<label for="{{ form.username.id_for_label }}">{% trans 'Username' %}</label> | ||
<input type="text" | ||
class="form-control" | ||
name="{{ form.username.name }}" | ||
id="{{ form.username.id_for_label }}" | ||
required | ||
autofocus/> | ||
{% if form.username.errors %} | ||
<div class="text-danger"> | ||
{% for error in form.username.errors %}<p>{{ error }}</p>{% endfor %} | ||
</div> | ||
{% endif %} | ||
</div> | ||
<div class="form-group"> | ||
<label for="{{ form.email.id_for_label }}">{% trans 'Email address' %}</label> | ||
<input type="email" | ||
class="form-control" | ||
name="{{ form.email.name }}" | ||
id="{{ form.email.id_for_label }}" | ||
required | ||
placeholder="[email protected]"/> | ||
{% if form.email.errors %} | ||
<div class="text-danger"> | ||
{% for error in form.email.errors %}<p>{{ error }}</p>{% endfor %} | ||
</div> | ||
{% endif %} | ||
</div> | ||
<div class="form-group"> | ||
<label for="{{ form.password1.id_for_label }}">{% trans 'Password' %}</label> | ||
<input type="password" | ||
class="form-control" | ||
name="{{ form.password1.name }}" | ||
id="{{ form.password1.id_for_label }}" | ||
required/> | ||
{% if form.password1.errors %} | ||
<div class="text-danger"> | ||
{% for error in form.password1.errors %}<p>{{ error }}</p>{% endfor %} | ||
</div> | ||
{% endif %} | ||
</div> | ||
<div class="form-group"> | ||
<label for="{{ form.password2.id_for_label }}">{% trans 'Confirm Password' %}</label> | ||
<input type="password" | ||
class="form-control" | ||
name="{{ form.password2.name }}" | ||
id="{{ form.password2.id_for_label }}" | ||
required/> | ||
{% if form.password2.errors %} | ||
<div class="text-danger"> | ||
{% for error in form.password2.errors %}<p>{{ error }}</p>{% endfor %} | ||
</div> | ||
{% endif %} | ||
</div> | ||
<div class="my-2"> | ||
<button class="btn btn-success btn-block mb-3" type="submit">{% trans 'Sign up' %}</button> | ||
</div> | ||
</form> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% load static i18n %} | ||
<div class="modal-header"> | ||
<h5 id="SaveDocumentModalTitle" class="modal-title">{% trans 'Where do you want to save your document?' %}</h5> | ||
<button type="button" | ||
class="btn-close" | ||
data-bs-dismiss="modal" | ||
aria-label="Close"/> | ||
</div> | ||
<div class="modal-body"> | ||
<div id="SaveDocumentModal" data-vue-component="SaveDocumentModal"></div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,9 +62,11 @@ | |
{% block head-css %}{% endblock %} | ||
{% block head-js %}{% endblock %} | ||
</head> | ||
<body class="{% block body-class %}{% endblock %}"> | ||
<body hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' | ||
class="{% block body-class %}{% endblock %}"> | ||
{% block header %}{% endblock %} | ||
{% block body-content %}{% endblock %} | ||
{% block footer %}{% endblock %} | ||
<script src="https://unpkg.com/[email protected]"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.