Skip to content

Commit

Permalink
Made changes I think I'll push this now
Browse files Browse the repository at this point in the history
  • Loading branch information
ariankordi committed Oct 18, 2017
1 parent 584cb91 commit e6985d6
Show file tree
Hide file tree
Showing 7 changed files with 362 additions and 37 deletions.
250 changes: 248 additions & 2 deletions closedverse_main/forbidden.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,256 @@
"aknet_1.0",
"reaidonaldtrump",
"pokefan2kg",
"pokefan2km",
"inklingsarehot",
"cosmicsansms",
"vinnasnauce",
"sackorye",
"caliemarie",
"pf2m.mp4",
"inklingsarehawt",
"obeyhelix",
"obeyhelix2",
"wigglerwednesday",
"yeahb0t",
"pf2m_was_here",
"pf2m.png",
"pf2mbackup",
"biotechnological",
"yeahbotbackup",
"pokefan2000m",
"nicememe420",
"publicmii",
"publicmii2",
"publicmii3",
"publicmii4",
"pf2memes",
"yeahbotreturns",
"pf2mlegit",
"giivasunner",
"yeahbotsback",
"nimda_esreviim",
"motodnetnin",
"heyboat",
"pf2mfinal",
"pf2m.ml",
"joingametips1337",
"pf2magain",
"publicmii5",
"siivagunner",
"pf2mlol",
"publicmii6",
"publicmii7",
"wiggierwednesday",
"y-man1",
"y-man2",
"y-man3",
"y-man4",
"y-man5",
"y-man6",
"y-man7",
"y-man8",
"y-man9",
"y-manten",
"y-man11",
"y-mantwelve",
"y-man_no1",
"y-man_no2",
"y-man_no3",
"y-man_no4",
"y-man_no5",
"y-man_no6",
"y-man_no7",
"y-man_no8",
"y-man_no9",
"y-man_no10",
"y-man_no11",
"y-man_no12",
"wiggnerwednesday",
"publicmii8",
"granddad777",
"publicmii9",
"publicmii10",
"publicmii11",
"pf2mplays",
"memeverse_midna",
"andim_esrevemem",
"pf2mcit",
"spindlyjohnny",
"blueeyeswitecena",
"pf2mtheundying",
"publicmii12",
"publicmii13",
"publicmii14",
"publicmii15",
"pf2mcit2",
"hardindaink",
"publicmii16",
"xx_pf2m_xx",
"mrred922",
"createanewid",
"publicmii17",
"pf2mreturns",
"olv.portal.memes",
"fgt555",
"justdoingthis4yt",
"publicmii18",
"eggalovania",
"publicmii19",
"publicmii1",
"pokefam2000memes",
"swegalovania",
"legalovania",
"publicmii21",
"publicmii22",
"publicmii23",
"meme_sch00l",
"e621.net",
"returnofthepf2m",
"timeb0t",
"pf2myetagain",
"pf2man",
"inklingbangerang",
"pf2mait",
"cantpunishdapf2m",
"lordofthepf2m",
"woomythief",
"woomyeater3d",
"thisispf2malt1",
"iampf2m",
"pf2000m",
"redesign_revenge",
"turndownforpf2m",
"boneighborhood",
"yeahdr0id",
"squidsoutforpf2m",
"eggieisaneko",
"makemvgreatagain",
"pf2msfilms",
"mydarncroissants",
"literallycantevn",
"pftubem",
"publicmii29",
"acountwellwasted",
"hyperbanhell",
"revengeofthe913",
"y-men_returns1",
"y-men_returns2",
"y-men_returns3",
"y-men_returns4",
"y-men_returns5",
"y-men_returns6",
"y-men_returns7",
"y-men_returns8",
"y-men_returns9",
"y-men_returns10",
"y-men_returns11",
"y-men_returns12",
"bugmen0t",
"timebotreturns",
"pf2mreturnsagain",
"playthisboys",
"b00tymatser",
"b00tymaster",
"pf2mtestnnid1",
"pf2mnt",
"pf2mmakesanewalt",
"justpf2mthings",
"throwaway_acct",
"pf2aaaaaaaaaargh",
"pf2mthrowawayacc",
"pf2mdoesthething",
"pf2mdoesathing",
"pf2mdoeslething",
"pf2mdidthething",
"createanewnnid",
"pf2mtestnnid2",
"pf2mtestnnid3",
"pf2mjp",
"pf2meu",
"pf-2manyaccounts",
"pftoomanycooks",
"pf2manycooks",
"pf2stop",
"pf2mtestnnid4",
"pf2mtestnnid5",
"pf2mtestnnid6",
"forkthepolice",
"iipf2m",
"pf2mbannedagain",
"throwawayacct420",
"throwawayacct421",
"throwawayacct422",
"throwawayacct423",
"throwawayacct424",
"throwawayacct425",
"throwawayacct426",
"throwawayacct427",
"throwawayacct428",
"throwawayacct429",
"emailbot",
"emailbot2",
"throwawayacc1337",
"throwawayacc1338",
"throwawayacc1339",
"throwawayacc430",
"bannedf2m",
"throwawayacc431",
"throwawayacc432",
"throwawayacc433",
"throwawayacc434",
"throwawayacc435",
"newpf2mmainmaybe",
"allaboutthatpf2m",
"throwawayacc436",
"throwawayacc437",
"throwawayacc438",
"throwawayacc439",
"hyperbanssucklol",
"throwawayacc440",
"throwawayacc441",
"throwawayacc442",
"throwawayacc443",
"throwawayacc444",
"throwawayacc445",
"pf2m.html",
"zztopkek",
"behel1231",
"behel1115",
"throwawayacc666",
"throwawayacc667",
"moke2anfkp",
"wiggerwednesday",
"sosmicmanssc",
"hnklingsareiot",
"gvdluifbenjot",
"nico_nico_niif2m",
"pf2m.com",
"miif2m",
"pf2mii",
"p-p-p-pf2m",
"pf2m.mp3",
"nicosarehot",
"nnnf2m",
"nyaf2m",
"whatamifighting4",
"pf2m-san",
"secret.pf2m.com",
"secrets.pf2m.com",
"bees.pf2m.com",
"olv.portal.bees",
"web.mii.pf2m.com",
"holupwaitaminute",
"webmii2",
"yeahphetkotto",
"topf2mabutterfly",
"commentbot",
"november_7th",
"november_8th",
"miis-cdn",
"567-343-0696",
"closedv.pf2m.com",
"archiveteam",
"cosmicsansms",
"lambiejammies",
"angelofyeahs",
"realyeahangel222",
Expand Down Expand Up @@ -95,7 +342,6 @@
"arm64arian",
"yse-s3-us",
"mvisfinally_ours",
"eggieisaneko",
"olv.portal.ban",
"pf2mdidnothing",
"ajx-j2-us",
Expand Down
52 changes: 39 additions & 13 deletions closedverse_main/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import BaseUserManager
from django.db.models import Q, QuerySet, Max, F, Count
from django.db.models import Q, QuerySet, Max, F, Count, Case, When
from django.utils import timezone
from django.forms.models import model_to_dict
from django.utils.dateformat import format
Expand Down Expand Up @@ -260,24 +260,31 @@ def get_followers(self, limit=50, offset=0, request=None):
def notification_count(self):
return self.notification_to.filter(read=False, merged_with=None).count()
def notification_read(self):
self.notification_to.filter(read=False).update(read=True)
# FIX THESE - See if they work
#notifications_new = self.notification_ids()
#self.notification_set.exclude(id__in=notifications_new).delete()
return True
return self.notification_to.filter(read=False).update(read=True)
def get_notifications(self):
return self.notification_to.filter(merged_with=None).order_by('-latest')[0:64]
""" Broken - gives segfault
notifications_new = self.notification_ids()
self.notification_set.exclude(id__in=notifications_new).delete()
def notification_ids(self):
notifications = list(self.notification_to.filter(merged_with=None).values_list('id', flat=True)[0:64])
for notification in notifications:
merges = self.notification_to.filter(merged_with=notification)
notifications.append(merges)
"""

# Admin can-manage
def can_manage(self):
if (self.level >= 2) or self.is_staff():
return True
return False
# Does user have authority over self?
def has_authority(self, user):
if self.is_staff():
return False
if (self.level < user.level):
return True
return False
def friend_state(self, other):
# Todo: return -1 for cannot, 0 for nothing, 1 for my friend pending, 2 for their friend pending, 3 for friends
query1 = other.fr_source.filter(target=self, finished=False).exists()
Expand Down Expand Up @@ -648,7 +655,9 @@ def can_yeah(self, request):
else:
return False
def can_rm(self, request):
return request.user.level > 0
if self.creator.has_authority(request.user):
return True
return False
def give_yeah(self, request):
if not request.user.has_freedom() and Yeah.objects.filter(by=request.user, created__gt=timezone.now() - timedelta(seconds=5)).exists():
return False
Expand Down Expand Up @@ -815,8 +824,11 @@ def can_yeah(self, request):
else:
return False
def can_rm(self, request):
if request.user.level > 0 or self.original_post.is_mine(request.user):
if self.creator.has_authority(request.user):
return True
if self.original_post.is_mine(request.user):
return True
return False
def give_yeah(self, request):
if not request.user.has_freedom() and Yeah.objects.filter(by=request.user, created__gt=timezone.now() - timedelta(seconds=5)).exists():
return False
Expand Down Expand Up @@ -1022,7 +1034,7 @@ def give_notification(user, type, to, post=None, comment=None):
# Or if user is to
# Or if yeah notifications are off and this is a yeah notification
user_is_self_unk = (not type == 3 and user == to)
is_notification_too_fast = user.notification_sender.filter(created__gt=timezone.now() - timedelta(seconds=5), to=to)
is_notification_too_fast = user.notification_sender.filter(created__gt=timezone.now() - timedelta(seconds=5), to=to, type=type).exclude(type=4)
user_no_yeahnotif = (not to.let_yeahnotifs and (type == 0 or type == 1))
if user_is_self_unk or is_notification_too_fast or user_no_yeahnotif:
return False
Expand Down Expand Up @@ -1099,17 +1111,30 @@ def conversation(self):
return Conversation.objects.create(source=self.source, target=self.target)
return conv.first()

def get_friendships(user, limit=50, offset=0, latest=False):
def get_friendships(user, limit=50, offset=0, latest=False, online_only=False):
if not limit:
return Friendship.objects.filter(Q(source=user) | Q(target=user)).order_by('-created')
if latest:
return Friendship.objects.filter(Q(source=user) | Q(target=user)).order_by('-latest')[offset:offset + limit]
if online_only:
delta = timezone.now() - timedelta(seconds=48)
awman = []
for friend in Friendship.objects.filter(Q(source=user) | Q(target=user)).order_by('-latest')[offset:offset + limit]:
if friend.other(user).last_login > delta:
awman.append(friend)
return awman
# Fix all of this at some point
# return Friendship.objects.filter(
#source=When(source__ne=user, source__last_login__gt=delta),
#target=When(target__ne=user, target__last_login__gt=delta)
#).order_by('-latest')[offset:offset + limit]
else:
return Friendship.objects.filter(Q(source=user) | Q(target=user)).order_by('-latest')[offset:offset + limit]
else:
return Friendship.objects.filter(Q(source=user) | Q(target=user)).order_by('-created')[offset:offset + limit]
def find_friendship(first, second):
return Friendship.objects.filter(Q(source=first) & Q(target=second) | Q(target=first) & Q(source=second)).order_by('-created').first()
def get_friendships_message(user, limit=20, offset=0):
friends_list = Friendship.get_friendships(user, limit, offset, True)
def get_friendships_message(user, limit=20, offset=0, online_only=False):
friends_list = Friendship.get_friendships(user, limit, offset, True, online_only)
friends = []
for friend in friends_list:
friends.append(friend.other(user))
Expand Down Expand Up @@ -1271,3 +1296,4 @@ class ThermostatTouch(models.Model):

def __str__(self):
return str(created) + " touched the thermostat, setting it to " + str(lvl) + " degrees celsius"
0
Loading

0 comments on commit e6985d6

Please sign in to comment.