diff --git a/apps/proxy/models.py b/apps/proxy/models.py index 82b36c99a7..1e1d7a5f25 100644 --- a/apps/proxy/models.py +++ b/apps/proxy/models.py @@ -261,12 +261,20 @@ def get_user_active_nodes(cls, user): base_query = cls.get_active_nodes() query = base_query.filter(level__lte=user.level) # 2. filter out nodes that has been occupied by other users - occupied_node_ids = UserProxyNodeOccupancy.get_occupied_node_ids() - query = query.exclude(id__in=occupied_node_ids) + occupied_node_ids = [ + i["proxy_node_id"] for i in UserProxyNodeOccupancy.get_occupied_node_ids() + ] + not_occupied_node_ids = [ + i["id"] for i in query.exclude(id__in=occupied_node_ids).values("id") + ] # 3. add nodes that has been occupied by this user - user_occupied_node_ids = UserProxyNodeOccupancy.get_user_occupied_node_ids(user) - query = query | base_query.filter(id__in=user_occupied_node_ids) - return query + user_occupied_node_ids = [ + i["proxy_node_id"] + for i in UserProxyNodeOccupancy.get_user_occupied_node_ids(user) + ] + return cls.objects.filter(id__in=not_occupied_node_ids) | cls.objects.filter( + id__in=user_occupied_node_ids + ) @classmethod def calc_total_traffic(cls): @@ -1016,7 +1024,8 @@ def check_and_incr_traffic(cls, user_id, proxy_node_id, traffic): @classmethod def get_user_occupancies(cls, user: User): - return cls._valid_occupancy_query().filter(user=user) + # no mater out of usage or not, return all occupancies + return cls.objects.filter(user=user) def human_total_traffic(self): return utils.traffic_format(self.total_traffic) diff --git a/templates/web/node_occupancy.html b/templates/web/node_occupancy.html index a976b00aeb..5e807eeb25 100644 --- a/templates/web/node_occupancy.html +++ b/templates/web/node_occupancy.html @@ -82,6 +82,7 @@

已购买

已用流量 总流量 进度 + 状态 @@ -96,6 +97,13 @@

已购买

{{ o.used_percentage }}% + + {% if o.out_of_usage %} + 失效 + {% else %} + 正常 + {% endif %} + {% endfor %}