Skip to content

Commit cfaa378

Browse files
committed
add source_url to edit and submit event
1 parent bf41823 commit cfaa378

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

backend/apps/events/views.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -730,17 +730,12 @@ def get_user_submissions(request):
730730
@api_view(["DELETE"])
731731
@ratelimit(key="ip", rate="30/hr", block=True)
732732
@jwt_required
733-
def delete_submission(request, submission_id):
733+
def delete_submission(request, event_id):
734734
try:
735-
submission = get_object_or_404(EventSubmission, id=submission_id)
736-
737-
if str(submission.submitted_by) != str(request.user_id):
738-
return Response(
739-
{"message": "Not authorized to delete this submission"},
740-
status=status.HTTP_403_FORBIDDEN
741-
)
735+
event = get_object_or_404(Events, id=event_id)
736+
submission = event.submission
742737

743-
if submission.reviewed_at and submission.created_event.status == "CONFIRMED":
738+
if event.status == "CONFIRMED":
744739
return Response({
745740
"message": "Approved submissions cannot be removed. Contact support if needed."
746741
}, status=status.HTTP_400_BAD_REQUEST)
@@ -889,6 +884,8 @@ def update_event(request, event_id):
889884
event.price = cleaned["price"]
890885
if "registration" in cleaned:
891886
event.registration = cleaned["registration"]
887+
if "source_url" in cleaned:
888+
event.source_url = cleaned.get("source_url")
892889

893890
# Update occurrences if provided
894891
if cleaned.get("occurrences"):

backend/utils/validation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,8 @@ def validate_event_data(data: Dict[str, Any]) -> Dict[str, Any]:
6969
if data.get("registration"):
7070
cleaned["registration"] = bool(data.get("registration"))
7171

72+
# Source URL
73+
if data.get("source_url"):
74+
cleaned["source_url"] = str(data.get("source_url")).strip() or None
75+
7276
return cleaned

frontend/src/features/events/components/EventEditForm.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export function EventEditForm({ event }: EventEditFormProps) {
3737
price: event.price ?? null,
3838
food: event.food || "",
3939
registration: event.registration || false,
40+
source_url: event.source_url || "",
4041
},
4142
});
4243

frontend/src/features/events/components/EventFormFields.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface EventFormData {
2626
price: number | null;
2727
food: string;
2828
registration: boolean;
29+
source_url: string;
2930
}
3031

3132
interface DeletedDate {
@@ -163,6 +164,28 @@ export function EventFormFields({
163164
)}
164165
/>
165166

167+
{/* Source URL */}
168+
<FormField
169+
control={form.control}
170+
name="source_url"
171+
render={({ field }) => (
172+
<FormItem>
173+
<FormLabel>Source URL</FormLabel>
174+
<FormControl>
175+
<Input
176+
{...field}
177+
type="url"
178+
placeholder="https://example.com/event"
179+
disabled={isDisabled}
180+
/>
181+
</FormControl>
182+
<p className="text-xs text-gray-500 dark:text-gray-400">
183+
Original source URL for this event
184+
</p>
185+
</FormItem>
186+
)}
187+
/>
188+
166189
{/* Dates */}
167190
<div className="space-y-4">
168191
<div className="flex items-center justify-between">

0 commit comments

Comments
 (0)