Skip to main content

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

  1. Add package to list of your already available django apps in settings.py

    Code:

INSTALLED_APPS = [

...

'violation',

]
  1. Run database migration to sync preset violation that the app ships with. Code:
>> python manage.py migrate
  1. Login your project admin panel and you should see VIOLATION added menu.

  2. 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 are BaseViolationMixin and CreateView

    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

Metadata

Release files for django-violation 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-violation 1.2.1
File Size Uploaded Provenance
django-violation-1.2.1.tar.gz 10.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-violation 1.2.1
File Interpreter ABI Platform
django_violation-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 24.3 kB

Release files / django-violation-1.2.1.tar.gz

Download URL django-violation-1.2.1.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
93c9b84153e1c40c12177aecb940041bf9893f3558a682c183228ea78ed0e88f
BLAKE2b-256 checksum
How to use checksums
fdd2e5efccd5d2f363ba1527d39fe0909f0e1a21a04b6aab69d038286c9ac34c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / django_violation-1.2.1-py3-none-any.whl

Download URL django_violation-1.2.1-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6159ef49cba5a348c2d15122dbcdc2c4e1045dfae3f3f92f2118ba48f9b97b2d
BLAKE2b-256 checksum
How to use checksums
7db7f7c84ff3512ce04e3a01320d36ad2d7b4682f113a5fce053415b05b18c9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Security for django-violation 1.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page