Skip to content

Instantly share code, notes, and snippets.

saschalalala

Block or report user

Report or block saschalalala

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View user_management.models.py
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
from django.db import models
from django.utils.translation import ugettext_lazy as _
from .managers import UserManager
class User(AbstractBaseUser, PermissionsMixin):
"""
User model, extends `django.contrib.auth.models.AbstractBaseUser`
@saschalalala
saschalalala / decorators.py
Created Jun 3, 2017
telegram_bot decorators
View decorators.py
def admin_only(func):
def check_permissions(*args, **kwargs):
bot = args[0]
update = args[1]
admin_ids = list(Player.objects.filter(gm=True).values_list('telegram_id', flat=True))
current_user = update.message.from_user
if current_user.id not in admin_ids:
update.message.reply_text("You are not allowed to do this, Troubleshooter. This incident will be reported")
message = "The user {} just entered a forbidden command.".format(current_user)
log_channel_id = Game.objects.get(pk=1).channel_id
View cookieconsent.js
var cookieconsent_wrapper = function() {
console.log("I am running");
// Stop from running again, if accidently included more than once.
if (window.hasCookieConsent) return;
window.hasCookieConsent = true;
/*
Constants
*/
@saschalalala
saschalalala / _dnf
Created Jun 8, 2015
zsh completion file for dnf
View _dnf
#compdef dnf
# Main dispatcher
_dnf()
{
local curcontext="$curcontext" state lstate line
_arguments -s \
'(- *)'{-h,--help}'[show the help message]' \
'(-t --tolerant)'{-t,--tolerant}'[be tolerant of errors]' \
You can’t perform that action at this time.