diff --git a/goodtimes/services.py b/goodtimes/services.py index 2cf522f..2626640 100644 --- a/goodtimes/services.py +++ b/goodtimes/services.py @@ -572,19 +572,18 @@ class EventFilterService: class MyEventFilterService: @staticmethod def filter_my_events_draft(user): - today = timezone.now().date() + # today = timezone.now().date() - current_and_future_events_query = Q( - start_date__lte=today, end_date__gte=today - ) | Q(start_date__gt=today) + # current_and_future_events_query = Q( + # start_date__lte=today, end_date__gte=today + # ) | Q(start_date__gt=today) events = Event.objects.filter( - current_and_future_events_query, draft=True, deleted=False, active=True, created_by=user, - ).distinct() + ) return events diff --git a/goodtimes/urls.py b/goodtimes/urls.py index ef5551b..f1fa376 100644 --- a/goodtimes/urls.py +++ b/goodtimes/urls.py @@ -45,7 +45,7 @@ urlpatterns = [ path('api/wallet/', include("manage_wallets.api.urls")), path("communications/", include("manage_communications.urls")), - # path('api/communications/', include("manage_communications.api.urls")), + path('api/communications/', include("manage_communications.api.urls")), # path('chat/', include('chat.urls')), # path('api/chat/', include("chat.api.urls")), diff --git a/manage_communications/api/serializers.py b/manage_communications/api/serializers.py index 8a13df7..68e35d4 100644 --- a/manage_communications/api/serializers.py +++ b/manage_communications/api/serializers.py @@ -62,11 +62,10 @@ class FeedbackSerializer(serializers.ModelSerializer): RATING_CHOICES = Feedback.RATING_CHOICES rating = serializers.ChoiceField(choices=RATING_CHOICES) - feedback_reaction = serializers.SerializerMethodField() class Meta: model = Feedback - fields = ['principal', 'email', 'comment', 'rating', 'feedback_reaction'] + fields = ['principal', 'email', 'comment', 'rating'] def get_feedback_reaction(self, obj): rating = obj.rating diff --git a/manage_communications/api/views.py b/manage_communications/api/views.py index c2fe6cc..b2da83a 100644 --- a/manage_communications/api/views.py +++ b/manage_communications/api/views.py @@ -32,6 +32,7 @@ class ContactUsView(APIView): return ApiResponse.success(data=serializer.data, message=constants.SUCCESS) + class TicketView(APIView): serializer_class = serializers.TicketsSerializer model = Tickets diff --git a/manage_communications/migrations/0002_remove_feedback_feedback_reaction_and_more.py b/manage_communications/migrations/0002_remove_feedback_feedback_reaction_and_more.py new file mode 100644 index 0000000..809ee3b --- /dev/null +++ b/manage_communications/migrations/0002_remove_feedback_feedback_reaction_and_more.py @@ -0,0 +1,25 @@ +# Generated by Django 5.0.2 on 2024-03-09 17:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("manage_communications", "0001_initial"), + ] + + operations = [ + migrations.RemoveField( + model_name="feedback", + name="feedback_reaction", + ), + migrations.AlterField( + model_name="feedback", + name="rating", + field=models.PositiveSmallIntegerField( + choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)], + help_text="Rating provided by the user", + ), + ), + ] diff --git a/manage_communications/models.py b/manage_communications/models.py index 73833be..72cf5f1 100644 --- a/manage_communications/models.py +++ b/manage_communications/models.py @@ -73,26 +73,14 @@ class Tickets(BaseModel): self.ticket_status = self.RESOLVED self.save() -class Feedback(BaseModel): - VERY_BAD = "Very Bad" - POOR = "Poor" - MEDIUM = "Medium" - GOOD = "Good" - EXCELLENT = "Excellent" +class Feedback(BaseModel): RATING_CHOICES = ( - (1, "1 Star"), - (2, "2 Stars"), - (3, "3 Stars"), - (4, "4 Stars"), - (5, "5 Stars"), - ) - FEEDBACK_REACTION = ( - (VERY_BAD, "Very Bad"), - (POOR, "Poor"), - (MEDIUM, "Medium"), - (GOOD, "Good"), - (EXCELLENT, "Excellent"), + (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, 5), ) principal = models.ForeignKey( @@ -106,13 +94,6 @@ class Feedback(BaseModel): email = models.EmailField(null=True, blank=True, help_text="Email address of the feedback provider") comment = models.TextField(help_text="Feedback comment") rating = models.PositiveSmallIntegerField(choices=RATING_CHOICES, help_text="Rating provided by the user") - feedback_reaction = models.CharField( - max_length=20, - choices=FEEDBACK_REACTION, - null=True, - blank=True, - help_text="Reaction associated with the feedback", - ) class Meta: db_table = "feedback" @@ -121,7 +102,5 @@ class Feedback(BaseModel): return f"Author: {self.principal}, Comment: {self.comment}, Rating: {self.rating}" def get_rating_display(self): - for value, label in self.RATING_CHOICES: - if value == self.rating: - return label - return "" + rating_labels = {value: label for value, label in self.RATING_CHOICES} + return rating_labels.get(self.rating, "") diff --git a/manage_events/api/views.py b/manage_events/api/views.py index 4ba9cc7..e9fcff7 100644 --- a/manage_events/api/views.py +++ b/manage_events/api/views.py @@ -269,7 +269,9 @@ class VenueListView(generics.ListAPIView): def get_queryset(self): # Ensures that a user sees only their venues - return Venue.objects.filter(created_by=self.request.user) + return Venue.objects.filter( + created_by=self.request.user, deleted=False, active=True + ) def list(self, request, *args, **kwargs): queryset = self.get_queryset() @@ -289,7 +291,7 @@ class VenueDetailView(generics.RetrieveUpdateDestroyAPIView): def get_queryset(self): # This ensures a user can only access their own venues - return self.queryset.filter(created_by=self.request.user) + return self.queryset.filter(created_by=self.request.user, deleted=False, active=True) class GeocodeAPIView(APIView):