django-violation is a reusable Django application for reporting illicit/improper acts.
Project description
django-violation
Description
Description Django-violation is a very simple app which serves the purpose of violation. It can easily be plugged into any django app of your choice with just little line of code/customization but with robust function.
Installation
>> pip install django-violation
Features
django-violation is shipped with basic features that is needed for reporting / flagging an item, post, image, user, thread etc as invalid.
Among some of its basic features are:
- An item cannot be submitted for violation by same person.
- Built-in django admin panel.
- Ability to redisplay rules that have been submitted by various users.
- Can be plugged with any django app.
- Highly customizable.
Future implementations
- Adding a UI interface.
Requirements
- Python >= 3.7
- Django >= 3.1
Usage
-
Add package to list of your already available django apps in settings.py
Code:
INSTALLED_APPS = [
...
'violation',
]
- Run database migration to sync preset violation that the app ships with. Code:
>> python manage.py migrate
-
Login your project admin panel and you should see VIOLATION added menu.
-
Next is to write a view code to load object you will like report.
CBV
For Lovers of class views, who want to customize to the core, import
BaseViolationViewMixin
i.e.
from violation.viewmixins.violation import BaseViolationMixin
Inherit the view class and supply other
CreateView
parameters other than form_class.Do something similar to this
from violation.views.violation import BaseViolationView class ThreadViolationView(BaseViolationView): model = YourModelClass template_name = ''
It's worth noting that
BaseViolationView
ancestors areBaseViolationMixin
andCreateView
FBV
Function base view user can follow this code logic
from django.shortcuts import render, get_object_or_404 from violation.forms.violation import ViolationForm from .models import Thread # where this a an imaginary thread you want to report TEMPLATE_URL = 'apps/threads' def report_thread(request, pk): template_name = f'{TEMPLATE_URL}/report_thread.html' thread = get_object_or_404(Thread, pk=pk) form_kwargs = { 'request': request, 'object': thread, } if request.method == 'POST': form = ViolationForm(data=request.POST, **form_kwargs) if form.is_valid(): form.save() else: form = ViolationForm(**form_kwargs) context = { 'form': form, 'thread': thread } return render(request, template_name, context=context)
Most importantly, it is worth noting that request and object keywords must be passed to form in your view.
For further customization, see project source code in github.
Limitations
- Lack of links and UI.
- Limited info on how to fully use.
Versioning
SemVer is the versioning style utilized for this app. For the versions available, see the tags on this repository releases.
License
This work uses MIT license
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-violation-1.2.1.tar.gz
.
File metadata
- Download URL: django-violation-1.2.1.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93c9b84153e1c40c12177aecb940041bf9893f3558a682c183228ea78ed0e88f |
|
MD5 | 65de86d5bd9ad74265e319dbef42b63f |
|
BLAKE2b-256 | fdd2e5efccd5d2f363ba1527d39fe0909f0e1a21a04b6aab69d038286c9ac34c |
File details
Details for the file django_violation-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: django_violation-1.2.1-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6159ef49cba5a348c2d15122dbcdc2c4e1045dfae3f3f92f2118ba48f9b97b2d |
|
MD5 | 3959635cb7fddaa28716f6856182c186 |
|
BLAKE2b-256 | 7db7f7c84ff3512ce04e3a01320d36ad2d7b4682f113a5fce053415b05b18c9c |