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
.progress { | |
position: fixed; | |
top: 0; | |
z-index: 1000; | |
height: 4px; | |
width: 100%; | |
border-radius: 2px; | |
background-clip: padding-box; | |
overflow: hidden; | |
} |
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
@contextmanager | |
def tenant(value): | |
""" | |
Context manager for tenants. Used to set and cleanup tennant. | |
param, value, can be Tenant object or id. | |
Using the context context manager | |
```python | |
with tenant(1): | |
Profile.objects.get(pk=1) |
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
class TenantAwareManager(Manager): | |
def get_queryset(self): | |
tenant_id = current_tenant_id() | |
# If the manager was built from a queryset using | |
# SomeQuerySet.as_manager() or SomeManager.from_queryset(), | |
# we want to use that queryset instead of TenantAwareQuerySet. | |
if self._queryset_class != QuerySet: | |
return super().get_queryset().filter(tenant__id=tenant_id) |
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
# Docker compose to set up containers for all services you need: | |
# VPN | |
# Sonarr, Radarr, Lidarr, Qbittorrent | |
# Non-VPN | |
# Plex, get_iplayer | |
# Before running docker-compose, you should pre-create all of the following folders. | |
# Folders for Docker State: | |
# /volume1/dockerdata. - root where this docker-compose.yml should live | |
# /volume1/dockerdata/plex - Plex config and DB | |
# /volume1/dockerdata/sonarr - Sonarr config and DB |
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
/** | |
* -- Overwrite Bootstrap Vars | |
*/ | |
$grid-breakpoints: ( | |
xs: 0, | |
sm: 576px, |
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
# https://gist.github.com/bmihelac/434fceb6ba8e752f08d3 | |
# https://github.com/django-import-export/django-import-export/issues/332 | |
from __future__ import unicode_literals | |
import mimetypes | |
from django.core.management.base import BaseCommand, CommandError | |
from django.utils import termcolors | |
from django.utils.encoding import force_text |
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
/* -------------------------------------------------------------------------- */ | |
// All Bootstrap 4 Sass Mixins [Cheat sheet] | |
// Updated to Bootstrap v4.5.x | |
// @author https://anschaef.de | |
// @see https://github.com/twbs/bootstrap/tree/master/scss/mixins | |
/* -------------------------------------------------------------------------- */ | |
/* | |
// ########################################################################## */ | |
// New cheat sheet for Bootstrap 5: |
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
.bd-callout { | |
padding: 1.25rem; | |
margin-top: 1.25rem; | |
margin-bottom: 1.25rem; | |
border: 1px solid #eee; | |
border-left-width: .25rem; | |
border-radius: .25rem | |
} | |
.bd-callout h4 { |
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
class DjangoModel(models.Model): | |
@classmethod | |
def from_db(cls, db, field_names, values): | |
instance = super().from_db(db, field_names, values) | |
instance._state.adding = False | |
instance._state.db = db | |
instance._old_values = dict(zip(field_names, values)) | |
return instance | |
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
# the mixin | |
class JSONFieldFormMixin(object): | |
""" | |
Given that a model has some kind of TextField ``json_storage_field`` with | |
a string of JSON formatted data inside, this mixin adds handling of this | |
field to a ModelForm. | |
It will read the text field, convert to Python dict, fill the form fields | |
that are given via ``json_fields`` and on saving will write this back to |
NewerOlder