Skip to content

Commit

Permalink
Update django (#1)
Browse files Browse the repository at this point in the history
* make compatible to django 4.0 - and rest_framework 3.13.1

* add format field in django model for image sharing
  • Loading branch information
mc51 authored Feb 9, 2022
1 parent ea9c920 commit cf7dc05
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
guni_clipster.py
*.crt
*.key
server/staticfiles/crypto/core
server/staticfiles/
*.pid

clipster/migrations/*
# Byte-compiled / optimized / DLL files
Expand Down
3 changes: 2 additions & 1 deletion clipster/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ class Clip(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
user = models.ForeignKey("auth.User", on_delete=models.CASCADE)
text = models.TextField(max_length=10000)
format = models.CharField(max_length=3, blank=True, default="txt")
device = models.CharField(max_length=100, blank=True, default="unspecified")

def __str__(self):
return f"user: {self.user} text: {self.text} created at: {self.created_at} device: {self.device}"
return f"user: {self.user} format: {self.format} text: {self.text} created at: {self.created_at} device: {self.device}"

class Meta:
ordering = ("created_at",)
2 changes: 1 addition & 1 deletion clipster/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ClipSerializer(serializers.ModelSerializer):

class Meta:
model = Clip
fields = ("id", "user", "text", "device", "created_at")
fields = ("id", "user", "format", "text", "device", "created_at")


class UserSerializer(serializers.ModelSerializer):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Django
dj_database_url
djangorestframework
gunicorn
whitenoise
whitenoise
11 changes: 11 additions & 0 deletions scripts/clipster.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[uwsgi]
chdir = ../
module = server.wsgi:application
plugin = python3
pidfile = clipster.pid
master = true
processes = 3
uwsgi-socket = 127.0.0.1:9999
chmod-socket = 660
vacuum = true

2 changes: 1 addition & 1 deletion server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
sys.exit(1)

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False

# Add your domain / ip to the allowed hosts
# "*" allows all !
Expand Down
7 changes: 3 additions & 4 deletions server/templates/rest_framework/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

<!DOCTYPE html>
<html>

<head>
{% block head %}

Expand Down Expand Up @@ -194,9 +193,9 @@ <h1>{{ name }}</h1>

<div class="response-info" aria-label="{% trans "response info" %}">
<pre class="prettyprint"><span class="meta nocode"><b>HTTP {{ response.status_code }} {{ response.status_text }}</b>{% for key, val in response_headers|items %}
<b>{{ key }}:</b> <span class="lit">{{ val|break_long_headers|urlize_quoted_links }}</span>{% endfor %}
<b>{{ key }}:</b> <span class="lit">{{ val|break_long_headers|urlize }}</span>{% endfor %}

</span>{{ content|urlize_quoted_links }}</pre>
</span>{{ content|urlize }}</pre>
</div>
</div>

Expand Down Expand Up @@ -339,4 +338,4 @@ <h1>{{ name }}</h1>
</body>
{% endblock %}

</html>
</html>
16 changes: 8 additions & 8 deletions server/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.urls import re_path, include, path
from django.shortcuts import redirect
from django.contrib import admin
from clipster import views as cb

urlpatterns = [
url(r"^admin/", admin.site.urls),
url(r"^$|^accounts/profile/", cb.ListClip.as_view(), name="list_clips_frontend"),
url(r"^share-clip/", cb.ShareClip.as_view(), name="share_clip"),
url(r"^api-auth/", include("rest_framework.urls", namespace="rest_framework")),
url(r"^copy-paste/", cb.CopyPaste.as_view(), name="copy_paste"),
url(r"^register/", cb.UserRegister.as_view(), name="register"),
url(r"^verify-user/", cb.UserVerify.as_view(), name="verify"),
re_path(r"^admin/", admin.site.urls),
re_path(r"^$|^accounts/profile/", cb.ListClip.as_view(), name="list_clips_frontend"),
re_path(r"^share-clip/", cb.ShareClip.as_view(), name="share_clip"),
re_path(r"^api-auth/", include("rest_framework.urls", namespace="rest_framework")),
re_path(r"^copy-paste/", cb.CopyPaste.as_view(), name="copy_paste"),
re_path(r"^register/", cb.UserRegister.as_view(), name="register"),
re_path(r"^verify-user/", cb.UserVerify.as_view(), name="verify"),
]

0 comments on commit cf7dc05

Please sign in to comment.