mirror of
https://github.com/Mistake35/Cedar-Django.git
synced 2026-07-18 00:21:14 +10:00
hmm
User created communities are now sorted by posts. Some small bug fixes, changed lazy error messages.
This commit is contained in:
@@ -87,7 +87,7 @@ class CommentAdmin(admin.ModelAdmin):
|
||||
|
||||
class CommunityAdmin(admin.ModelAdmin):
|
||||
raw_id_fields = ('creator', )
|
||||
list_display = ('id', 'name', 'description', 'type', 'creator', 'is_rm', 'is_feature', 'require_auth')
|
||||
list_display = ('id', 'name', 'description', 'type', 'creator', 'popularity', 'is_rm', 'is_feature', 'require_auth')
|
||||
search_fields = ('id', 'unique_id', 'name', 'description', )
|
||||
actions = [Hide_content, Show_content, Feature_community, Unfeature_community, force_login, unforce_login]
|
||||
def get_queryset(self, request):
|
||||
|
||||
@@ -143,6 +143,7 @@ class User(models.Model):
|
||||
user_agent = models.TextField(null=True, blank=True)
|
||||
# C Tokens are things that let you make communities and shit.
|
||||
c_tokens = models.IntegerField(default=1)
|
||||
protect_data = models.BooleanField(default=False)
|
||||
|
||||
# Things that don't have to do with auth lol
|
||||
hide_online = models.BooleanField(default=False)
|
||||
@@ -639,6 +640,10 @@ class Community(models.Model):
|
||||
objects = PostManager()
|
||||
real = models.Manager()
|
||||
def popularity(self):
|
||||
if self.creator:
|
||||
# don't count posts from the community owner.
|
||||
popularity = Post.objects.filter(community=self).exclude(creator=self.creator).count()
|
||||
else:
|
||||
popularity = Post.objects.filter(community=self).count()
|
||||
return popularity
|
||||
def __str__(self):
|
||||
|
||||
@@ -74,11 +74,11 @@
|
||||
{% if feature %}
|
||||
{% community_page_element feature "Featured Communities" True %}
|
||||
{% endif %}
|
||||
{% community_page_element general "General Communities" %}
|
||||
{% community_page_element game "Game Communities" %}
|
||||
{% community_page_element special "Special Communities" %}
|
||||
{% community_page_element user_communities "Popular User-Created communities" %}
|
||||
{% if my_communities %}{% community_page_element my_communities "My communities" %}{% endif %}
|
||||
{% if general %}{% community_page_element general "General Communities" %}{% endif %}
|
||||
{% if game %}{% community_page_element game "Game Communities" %}{% endif %}
|
||||
{% if special %}{% community_page_element special "Special Communities" %}{% endif %}
|
||||
{% if user_communities %}{% community_page_element user_communities "Popular User-Created Communities" %}{% endif %}
|
||||
{% if my_communities %}{% community_page_element my_communities "My Communities" %}{% endif %}
|
||||
<a href="{% url "main:community-viewall" "gen" %}" class="big-button">Show more</a>
|
||||
</div>
|
||||
<div id="community-guide-footer">
|
||||
|
||||
@@ -66,7 +66,7 @@ def community_list(request):
|
||||
WelcomeMSG = welcomemsg.objects.filter(show=True).order_by('-order', '-id')
|
||||
announcements = Post.objects.filter(community__tags='announcements').order_by('-id')[:6]
|
||||
if request.user.is_authenticated:
|
||||
my_communities = obj.filter(type=3, creator=request.user).order_by('-created')[0:8]
|
||||
my_communities = obj.filter(creator=request.user).order_by('-created')[0:12]
|
||||
else:
|
||||
my_communities = None
|
||||
return render(request, 'closedverse_main/community_list.html', {
|
||||
@@ -76,10 +76,10 @@ def community_list(request):
|
||||
'WelcomeMSG': WelcomeMSG,
|
||||
'availableads': availableads,
|
||||
'classes': classes,
|
||||
'general': obj.filter(type=0).order_by('-created')[0:8],
|
||||
'game': obj.filter(type=1).order_by('-created')[0:8],
|
||||
'special': obj.filter(type=2).order_by('-created')[0:8],
|
||||
'user_communities': sorted(obj.filter(type=3), key=lambda x: x.popularity(), reverse=True)[0:8],
|
||||
'general': obj.filter(type=0).order_by('-created')[0:12],
|
||||
'game': obj.filter(type=1).order_by('-created')[0:12],
|
||||
'special': obj.filter(type=2).order_by('-created')[0:12],
|
||||
'user_communities': sorted(obj.filter(type=3), key=lambda x: x.popularity(), reverse=True)[0:12],
|
||||
'my_communities': my_communities,
|
||||
'feature': obj.filter(is_feature=True).order_by('-created'),
|
||||
'favorites': favorites,
|
||||
@@ -986,9 +986,11 @@ def community_tools_set(request, community):
|
||||
if not can_edit:
|
||||
return HttpResponseForbidden()
|
||||
if len(request.POST.get('community_name')) == 0 or len(request.POST.get('community_name')) >= 100:
|
||||
return json_response('bad name')
|
||||
return json_response('Your community name is either too short or too long.')
|
||||
if len(request.POST.get('community_description')) >= 1024:
|
||||
return json_response('bad description')
|
||||
return json_response('Your community description is too long.')
|
||||
if int(request.POST.get('community_platform')) >= 8:
|
||||
return json_response('Invalid Platform type.')
|
||||
if the_community.is_rm:
|
||||
return json_response('Community is removed')
|
||||
if the_community.type == 4:
|
||||
@@ -1066,6 +1068,8 @@ def community_create_action(request):
|
||||
return json_response('Your community name is either too short or too long.')
|
||||
if len(request.POST.get('community_description')) >= 1024:
|
||||
return json_response('Your community description is too long.')
|
||||
if int(request.POST.get('community_platform')) >= 8:
|
||||
return json_response('Invalid Platform type.')
|
||||
get = request.POST.get
|
||||
user.c_tokens -= 1
|
||||
user.save()
|
||||
@@ -1709,6 +1713,8 @@ def user_tools_meta(request, username):
|
||||
raise Http404()
|
||||
user = get_object_or_404(User, username__iexact=username)
|
||||
profile = user.profile()
|
||||
if user.protect_data:
|
||||
return json_response('This user\'s data has been locked.')
|
||||
# check if the requesting user is allowed to view someone
|
||||
if user.has_authority(request.user):
|
||||
raise Http404()
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 3.4 KiB |
Reference in New Issue
Block a user