@@ -38,6 +38,11 @@ class Meta:
3838 "placeholder" : "팀 규칙을 마크다운 형식으로 작성해주세요\n \n 예:\n # 회의 규칙\n - 주 1회 수요일 19시\n - 지각 3회 = 경고\n \n # 코드 리뷰\n - PR 생성 후 2시간 내 리뷰\n - 최소 2명 승인 필수" ,
3939 "rows" : 6 ,
4040 }),
41+ "related_links" : forms .Textarea (attrs = {
42+ "class" : "form-control" ,
43+ "placeholder" : "관련 링크를 마크다운 형식으로 작성해주세요\n \n 예:\n [Notion](https://notion.so/...)\n [Figma](https://figma.com/...)\n [GitHub](https://github.com/...)" ,
44+ "rows" : 6 ,
45+ }),
4146 "is_favorite" : forms .CheckboxInput (attrs = {
4247 "class" : "form-check-input" ,
4348 }),
@@ -50,58 +55,10 @@ def clean_title(self):
5055 raise forms .ValidationError ("서비스명은 필수입니다." )
5156 return title
5257
53-
54- class ProjectRelatedLinksForm (forms .Form ):
55- """
56- 관련 링크 별도 폼 (AJAX 업데이트용)
57- """
58-
59- notion_url = forms .URLField (
60- required = False ,
61- label = "Notion" ,
62- widget = forms .URLInput (attrs = {
63- "class" : "form-control" ,
64- "placeholder" : "Notion 링크를 입력하세요" ,
65- }),
66- )
67-
68- figma_url = forms .URLField (
69- required = False ,
70- label = "Figma" ,
71- widget = forms .URLInput (attrs = {
72- "class" : "form-control" ,
73- "placeholder" : "Figma 링크를 입력하세요" ,
74- }),
75- )
76-
77- github_url = forms .URLField (
78- required = False ,
79- label = "GitHub" ,
80- widget = forms .URLInput (attrs = {
81- "class" : "form-control" ,
82- "placeholder" : "GitHub 링크를 입력하세요" ,
83- }),
84- )
85-
86- def clean (self ):
87- """링크가 1개 이상 입력되는지 확인"""
88- cleaned_data = super ().clean ()
89- has_link = any ([
90- cleaned_data .get ("notion_url" ),
91- cleaned_data .get ("figma_url" ),
92- cleaned_data .get ("github_url" ),
93- ])
94- if not has_link :
95- raise forms .ValidationError ("최소 1개 이상의 링크를 입력해주세요." )
96- return cleaned_data
97-
98- def to_dict (self ):
99- """폼 데이터를 딕셔너리로 변환 (JSONField용)"""
100- if not self .is_valid ():
101- return {}
102-
103- return {
104- "notion" : self .cleaned_data .get ("notion_url" ) or None ,
105- "figma" : self .cleaned_data .get ("figma_url" ) or None ,
106- "github" : self .cleaned_data .get ("github_url" ) or None ,
107- }
58+ def clean_related_links (self ):
59+ """관련 링크 정리 - "{}" 같은 빈 값 제거"""
60+ related_links = self .cleaned_data .get ("related_links" , "" ).strip ()
61+ # "{}" 또는 빈 문자열이면 None 반환
62+ if not related_links or related_links == "{}" :
63+ return None
64+ return related_links
0 commit comments