Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
user = models.ForeignKey(User, related_name='comment_like_user')
score = models.IntegerField(default=0, blank=True)
class Report(models.Model):
user = models.ForeignKey(User, related_name='report_user')
post = models.ForeignKey(Post, related_name='report_post')
class Meta:
unique_together = (("post", "user"),)
post_save.connect(Stream.add_post, sender=Post)
post_save.connect(Likes.user_like_post, sender=Likes)
#post_delete.connect(Likes.user_unlike_post, sender=Likes)
post_save.connect(Post.change_tag_slug, sender=Tag)
post_save.connect(Notif.add_comment, sender=Comments)
def read_list(self, object_list, bundle):
Notif.objects.filter(user=bundle.request.user).update(seen=True)
return object_list.filter(user=bundle.request.user)
return None
comment = instance
post = comment.object_pk
if comment.user != post.user:
notif = send_notif(user=post.user, type=2, post=post, actor=comment.user)
for notif in Notif.objects.filter(type=2, post=post):
for act in Notif_actors.objects.filter(notif=notif):
if act.actor != comment.user:
send_notif(user=act.actor, type=2, post=post, actor=comment.user)
#print act.actor_id
class Notif_actors(models.Model):
notif = models.ForeignKey(Notif, related_name="notif")
actor = models.ForeignKey(User, related_name="actor")
class App_data(models.Model):
name = models.CharField(max_length=250)
file = models.FileField(upload_to='app')
version = models.CharField(max_length=50)
version_code = models.IntegerField(default=0, blank=True)
current = models.BooleanField(default=1)
class Comments(models.Model):
comment = models.TextField()
submit_date = models.DateTimeField(auto_now_add=True)
ip_address = models.IPAddressField(default='127.0.0.1', db_index=True)
is_public = models.BooleanField(default=False, db_index=True)
def make_approve(self, request, queryset):
for obj in queryset:
Post.objects.filter(pk=obj.id)\
.update(status=Post.APPROVED, timestamp=time.time())
for obj in queryset:
send_notif(user=obj.user, type=Notif.APPROVE, post=obj, actor=request.user)
def send_notif(user, type, post, actor, seen=False):
notif, created = Notif.objects.get_or_create(user=user, type=type, post=post)
notif.seen = seen
notif.date = datetime.now()
notif.save()
Notif_actors.objects.get_or_create(notif=notif, actor=actor)
return notif
@register.filter
def get_user_notify(userid):
print "user id ", userid
notify = Notif.objects.all().filter(user_id=userid, seen=False).count()
return notify
def fault(self, request, queryset):
for obj in queryset:
Post.objects.filter(pk=obj.id).update(status=Post.FAULT, report=0)
#print obj.status
#obj.status = Post.FAULT
#print obj.status
#obj.save()
user = obj.user
user.profile.fault = user.profile.fault+1
user.profile.save()
for obj in queryset:
send_notif(user=obj.user, type=Notif.FAULT, post=obj, actor=request.user)