-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
7 changed files
with
142 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from django.contrib import admin | ||
from django.http import HttpResponse | ||
from django.urls import path | ||
from django.utils.decorators import method_decorator | ||
from django.views.decorators.csrf import csrf_exempt | ||
|
||
from . import models | ||
|
||
|
||
@admin.register(models.Bookmark) | ||
class BookmarkAdmin(admin.ModelAdmin): | ||
list_display = ('name', 'url', 'is_active') | ||
list_filter = ('is_active',) | ||
list_editable = ('is_active',) | ||
|
||
def get_urls(self): | ||
urls = super().get_urls() | ||
custom_urls = [ | ||
path('add-bookmark', self.admin_site.admin_view(self.add_bookmark_view), name='admin_reskin_add_bookmark'), | ||
] | ||
return custom_urls + urls | ||
|
||
@method_decorator(csrf_exempt) | ||
def add_bookmark_view(self, request): | ||
if request.method == 'POST': | ||
name = request.POST.get('name') | ||
url = request.POST.get('url') | ||
models.Bookmark.objects.create( | ||
name=name, | ||
url=url, | ||
) | ||
return HttpResponse() |
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,23 @@ | ||
# Generated by Django 3.2 on 2021-10-21 03:43 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Bookmark', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=45)), | ||
('url', models.CharField(max_length=1000)), | ||
('is_active', models.BooleanField(default=True)), | ||
], | ||
), | ||
] |
Empty file.
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,10 @@ | ||
from django.db import models | ||
|
||
|
||
class Bookmark(models.Model): | ||
name = models.CharField(max_length=45) | ||
url = models.CharField(max_length=1000) | ||
is_active = models.BooleanField(default=True) | ||
|
||
def __str__(self): | ||
return self.name |
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